ControllerShortcutSettingData.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. public static class ControllerShortcutSettingData
  6. {
  7. public static ControllerShortcutSettingData.OvrControllerShortcutConfig config
  8. {
  9. get
  10. {
  11. ControllerShortcutSettingData.LoadDefault();
  12. return ControllerShortcutSettingData.m_Config;
  13. }
  14. }
  15. public static void LoadDefault()
  16. {
  17. if (ControllerShortcutSettingData.m_IsLoadedDefault)
  18. {
  19. return;
  20. }
  21. ControllerShortcutSettingData.m_IsLoadedDefault = true;
  22. ControllerShortcutSettingData.m_Config = ControllerShortcutSettingData.m_Config.ReadAndSet();
  23. }
  24. private static ControllerShortcutSettingData.OvrControllerShortcutConfig m_Config = new ControllerShortcutSettingData.OvrControllerShortcutConfig();
  25. private static bool m_IsLoadedDefault = false;
  26. [Serializable]
  27. public class OvrControllerShortcutConfig : ISerializationCallbackReceiver
  28. {
  29. public void OnBeforeSerialize()
  30. {
  31. this.m_nVersion = 1350;
  32. }
  33. public void OnAfterDeserialize()
  34. {
  35. }
  36. public bool Write()
  37. {
  38. string contents = JsonUtility.ToJson(this, true);
  39. string path = UTY.gameProjectPath + "\\OvrControllerShortcutConfig.json";
  40. try
  41. {
  42. File.WriteAllText(path, contents);
  43. }
  44. catch
  45. {
  46. Debug.LogError("OvrControllerShortcutConfig.json の書き込みに失敗。");
  47. return false;
  48. }
  49. return true;
  50. }
  51. public ControllerShortcutSettingData.OvrControllerShortcutConfig ReadAndSet()
  52. {
  53. string path = UTY.gameProjectPath + "\\OvrControllerShortcutConfig.json";
  54. if (!File.Exists(path))
  55. {
  56. this.CreateDefaultData();
  57. this.Write();
  58. }
  59. string json;
  60. try
  61. {
  62. json = File.ReadAllText(path);
  63. }
  64. catch
  65. {
  66. Debug.LogError("OvrControllerShortcutConfig.json の読込に失敗。");
  67. return this;
  68. }
  69. return JsonUtility.FromJson<ControllerShortcutSettingData.OvrControllerShortcutConfig>(json);
  70. }
  71. private void CreateDefaultData()
  72. {
  73. this.FaceListRight = new List<PhotoFaceDataShortcut.FaceData>();
  74. List<PhotoFaceData> list = new List<PhotoFaceData>();
  75. list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["通常"]));
  76. list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["微笑み"]));
  77. list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["にっこり"]));
  78. list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["優しさ"]));
  79. list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["ぷんすか"]));
  80. list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["むー"]));
  81. list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["泣き"]));
  82. list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["ダンスジト目"]));
  83. for (int i = 0; i < list.Count; i++)
  84. {
  85. PhotoFaceDataShortcut.FaceData faceData = new PhotoFaceDataShortcut.FaceData();
  86. faceData.data = list[i];
  87. this.FaceListRight.Add(faceData);
  88. }
  89. this.FaceListLeft = new List<PhotoFaceDataShortcut.FaceData>();
  90. for (int j = 0; j < list.Count; j++)
  91. {
  92. PhotoFaceDataShortcut.FaceData faceData2 = new PhotoFaceDataShortcut.FaceData();
  93. faceData2.data = list[j];
  94. this.FaceListLeft.Add(faceData2);
  95. }
  96. this.isDirectMode = true;
  97. this.isEveryShowMode = true;
  98. this.maintainPelvisPosition = 0.3f;
  99. this.bodyPosStiffness = 0.55f;
  100. this.bodyRotStiffness = 0.1f;
  101. this.chestRotationWeight = 0.3f;
  102. this.selfCameraFOV = 0.5f;
  103. this.use1TrackerForHead = false;
  104. this.use23TrackerForFoot = false;
  105. this.use12TrackerForFoot = false;
  106. }
  107. public bool isDirectMode
  108. {
  109. get
  110. {
  111. return this.IsDirectShortcutMode;
  112. }
  113. set
  114. {
  115. this.IsDirectShortcutMode = value;
  116. }
  117. }
  118. public bool isEveryShowMode
  119. {
  120. get
  121. {
  122. return this.IsEveryShowMode;
  123. }
  124. set
  125. {
  126. this.IsEveryShowMode = value;
  127. }
  128. }
  129. public List<PhotoFaceDataShortcut.FaceData> faceListRight
  130. {
  131. get
  132. {
  133. return this.FaceListRight;
  134. }
  135. set
  136. {
  137. this.FaceListRight = value;
  138. }
  139. }
  140. public List<PhotoFaceDataShortcut.FaceData> faceListLeft
  141. {
  142. get
  143. {
  144. return this.FaceListLeft;
  145. }
  146. set
  147. {
  148. this.FaceListLeft = value;
  149. }
  150. }
  151. public float maintainPelvisPosition
  152. {
  153. get
  154. {
  155. return this.MaintainPelvisPosition;
  156. }
  157. set
  158. {
  159. this.MaintainPelvisPosition = Mathf.Clamp(value, 0f, 1f);
  160. }
  161. }
  162. public float bodyPosStiffness
  163. {
  164. get
  165. {
  166. return this.BodyPosStiffness;
  167. }
  168. set
  169. {
  170. this.BodyPosStiffness = Mathf.Clamp(value, 0f, 1f);
  171. }
  172. }
  173. public float bodyRotStiffness
  174. {
  175. get
  176. {
  177. return this.BodyRotStiffness;
  178. }
  179. set
  180. {
  181. this.BodyRotStiffness = Mathf.Clamp(value, 0f, 1f);
  182. }
  183. }
  184. public float chestRotationWeight
  185. {
  186. get
  187. {
  188. return this.ChestRotationWeight;
  189. }
  190. set
  191. {
  192. this.ChestRotationWeight = Mathf.Clamp(value, 0f, 1f);
  193. }
  194. }
  195. public float selfCameraFOV
  196. {
  197. get
  198. {
  199. return this.SelfCameraFOV;
  200. }
  201. set
  202. {
  203. this.SelfCameraFOV = Mathf.Clamp(value, 0f, 1f);
  204. }
  205. }
  206. public bool use1TrackerForHead
  207. {
  208. get
  209. {
  210. return this.Use1TrackerForHead;
  211. }
  212. set
  213. {
  214. this.Use1TrackerForHead = value;
  215. }
  216. }
  217. public bool use23TrackerForFoot
  218. {
  219. get
  220. {
  221. return this.Use23TrackerForFoot;
  222. }
  223. set
  224. {
  225. this.Use23TrackerForFoot = value;
  226. }
  227. }
  228. public bool use12TrackerForFoot
  229. {
  230. get
  231. {
  232. return this.Use12TrackerForFoot;
  233. }
  234. set
  235. {
  236. this.Use12TrackerForFoot = value;
  237. }
  238. }
  239. private const string CONF_NAME = "OvrControllerShortcutConfig.json";
  240. [SerializeField]
  241. private int m_nVersion = 1350;
  242. [SerializeField]
  243. private bool IsDirectShortcutMode = true;
  244. [SerializeField]
  245. private bool IsEveryShowMode = true;
  246. [SerializeField]
  247. private List<PhotoFaceDataShortcut.FaceData> FaceListRight = new List<PhotoFaceDataShortcut.FaceData>();
  248. [SerializeField]
  249. private List<PhotoFaceDataShortcut.FaceData> FaceListLeft = new List<PhotoFaceDataShortcut.FaceData>();
  250. [SerializeField]
  251. private float MaintainPelvisPosition = 0.3f;
  252. [SerializeField]
  253. private float BodyPosStiffness = 0.55f;
  254. [SerializeField]
  255. private float BodyRotStiffness = 0.1f;
  256. [SerializeField]
  257. private float ChestRotationWeight = 0.3f;
  258. [SerializeField]
  259. private float SelfCameraFOV = 0.5f;
  260. [SerializeField]
  261. private bool Use1TrackerForHead;
  262. [SerializeField]
  263. private bool Use23TrackerForFoot;
  264. [SerializeField]
  265. private bool Use12TrackerForFoot;
  266. }
  267. }