123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- public static class ControllerShortcutSettingData
- {
- public static ControllerShortcutSettingData.OvrControllerShortcutConfig config
- {
- get
- {
- ControllerShortcutSettingData.LoadDefault();
- return ControllerShortcutSettingData.m_Config;
- }
- }
- public static void LoadDefault()
- {
- if (ControllerShortcutSettingData.m_IsLoadedDefault)
- {
- return;
- }
- ControllerShortcutSettingData.m_IsLoadedDefault = true;
- ControllerShortcutSettingData.m_Config = ControllerShortcutSettingData.m_Config.ReadAndSet();
- }
- private static ControllerShortcutSettingData.OvrControllerShortcutConfig m_Config = new ControllerShortcutSettingData.OvrControllerShortcutConfig();
- private static bool m_IsLoadedDefault = false;
- [Serializable]
- public class OvrControllerShortcutConfig : ISerializationCallbackReceiver
- {
- public void OnBeforeSerialize()
- {
- this.m_nVersion = 1200;
- }
- public void OnAfterDeserialize()
- {
- }
- public bool Write()
- {
- string contents = JsonUtility.ToJson(this, true);
- string path = Path.GetFullPath(".\\") + "OvrControllerShortcutConfig.json";
- try
- {
- File.WriteAllText(path, contents);
- }
- catch
- {
- Debug.LogError("OvrControllerShortcutConfig.json の書き込みに失敗。");
- return false;
- }
- return true;
- }
- public ControllerShortcutSettingData.OvrControllerShortcutConfig ReadAndSet()
- {
- string path = Path.GetFullPath(".\\") + "OvrControllerShortcutConfig.json";
- if (!File.Exists(path))
- {
- this.CreateDefaultData();
- this.Write();
- }
- string json;
- try
- {
- json = File.ReadAllText(path);
- }
- catch
- {
- Debug.LogError("OvrControllerShortcutConfig.json の読込に失敗。");
- return this;
- }
- return JsonUtility.FromJson<ControllerShortcutSettingData.OvrControllerShortcutConfig>(json);
- }
- private void CreateDefaultData()
- {
- this.FaceListRight = new List<PhotoFaceDataShortcut.FaceData>();
- List<PhotoFaceData> list = new List<PhotoFaceData>();
- list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["通常"]));
- list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["微笑み"]));
- list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["にっこり"]));
- list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["優しさ"]));
- list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["ぷんすか"]));
- list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["むー"]));
- list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["泣き"]));
- list.Add(PhotoFaceData.Get((long)PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic["ダンスジト目"]));
- for (int i = 0; i < list.Count; i++)
- {
- PhotoFaceDataShortcut.FaceData faceData = new PhotoFaceDataShortcut.FaceData();
- faceData.data = list[i];
- this.FaceListRight.Add(faceData);
- }
- this.FaceListLeft = new List<PhotoFaceDataShortcut.FaceData>();
- for (int j = 0; j < list.Count; j++)
- {
- PhotoFaceDataShortcut.FaceData faceData2 = new PhotoFaceDataShortcut.FaceData();
- faceData2.data = list[j];
- this.FaceListLeft.Add(faceData2);
- }
- this.isDirectMode = true;
- this.isEveryShowMode = true;
- this.maintainPelvisPosition = 0.3f;
- this.bodyPosStiffness = 0.55f;
- this.bodyRotStiffness = 0.1f;
- this.chestRotationWeight = 0.3f;
- this.selfCameraFOV = 0.5f;
- this.use1TrackerForHead = false;
- this.use23TrackerForFoot = false;
- this.use12TrackerForFoot = false;
- }
- public bool isDirectMode
- {
- get
- {
- return this.IsDirectShortcutMode;
- }
- set
- {
- this.IsDirectShortcutMode = value;
- }
- }
- public bool isEveryShowMode
- {
- get
- {
- return this.IsEveryShowMode;
- }
- set
- {
- this.IsEveryShowMode = value;
- }
- }
- public List<PhotoFaceDataShortcut.FaceData> faceListRight
- {
- get
- {
- return this.FaceListRight;
- }
- set
- {
- this.FaceListRight = value;
- }
- }
- public List<PhotoFaceDataShortcut.FaceData> faceListLeft
- {
- get
- {
- return this.FaceListLeft;
- }
- set
- {
- this.FaceListLeft = value;
- }
- }
- public float maintainPelvisPosition
- {
- get
- {
- return this.MaintainPelvisPosition;
- }
- set
- {
- this.MaintainPelvisPosition = Mathf.Clamp(value, 0f, 1f);
- }
- }
- public float bodyPosStiffness
- {
- get
- {
- return this.BodyPosStiffness;
- }
- set
- {
- this.BodyPosStiffness = Mathf.Clamp(value, 0f, 1f);
- }
- }
- public float bodyRotStiffness
- {
- get
- {
- return this.BodyRotStiffness;
- }
- set
- {
- this.BodyRotStiffness = Mathf.Clamp(value, 0f, 1f);
- }
- }
- public float chestRotationWeight
- {
- get
- {
- return this.ChestRotationWeight;
- }
- set
- {
- this.ChestRotationWeight = Mathf.Clamp(value, 0f, 1f);
- }
- }
- public float selfCameraFOV
- {
- get
- {
- return this.SelfCameraFOV;
- }
- set
- {
- this.SelfCameraFOV = Mathf.Clamp(value, 0f, 1f);
- }
- }
- public bool use1TrackerForHead
- {
- get
- {
- return this.Use1TrackerForHead;
- }
- set
- {
- this.Use1TrackerForHead = value;
- }
- }
- public bool use23TrackerForFoot
- {
- get
- {
- return this.Use23TrackerForFoot;
- }
- set
- {
- this.Use23TrackerForFoot = value;
- }
- }
- public bool use12TrackerForFoot
- {
- get
- {
- return this.Use12TrackerForFoot;
- }
- set
- {
- this.Use12TrackerForFoot = value;
- }
- }
- private const string CONF_NAME = "OvrControllerShortcutConfig.json";
- [SerializeField]
- private int m_nVersion = 1200;
- [SerializeField]
- private bool IsDirectShortcutMode = true;
- [SerializeField]
- private bool IsEveryShowMode = true;
- [SerializeField]
- private List<PhotoFaceDataShortcut.FaceData> FaceListRight = new List<PhotoFaceDataShortcut.FaceData>();
- [SerializeField]
- private List<PhotoFaceDataShortcut.FaceData> FaceListLeft = new List<PhotoFaceDataShortcut.FaceData>();
- [SerializeField]
- private float MaintainPelvisPosition = 0.3f;
- [SerializeField]
- private float BodyPosStiffness = 0.55f;
- [SerializeField]
- private float BodyRotStiffness = 0.1f;
- [SerializeField]
- private float ChestRotationWeight = 0.3f;
- [SerializeField]
- private float SelfCameraFOV = 0.5f;
- [SerializeField]
- private bool Use1TrackerForHead;
- [SerializeField]
- private bool Use23TrackerForFoot;
- [SerializeField]
- private bool Use12TrackerForFoot;
- }
- }
|