Beispiel #1
0
        //This one now just reads from the gesture bank file.
        public static List <Gesture> GetGestureBank(string networkName)
        {
            List <Gesture> gestureBank        = new List <Gesture>();
            string         gesturesPath       = Application.streamingAssetsPath + Config.NEURAL_NET_PATH + networkName + "/GestureBank.txt";
            string         gesturesFolderPath = Application.streamingAssetsPath + Config.NEURAL_NET_PATH + networkName + "/Gestures/";

            //Check if path exists
            if (System.IO.File.Exists(gesturesPath))
            {
                string[]        lines = System.IO.File.ReadAllLines(gesturesPath);
                GestureBankStub stub  = JsonUtility.FromJson <GestureBankStub>(string.Concat(lines));
                return(stub.gestures);
            }
            else if (System.IO.Directory.Exists(gesturesFolderPath))
            {
                return(GetGestureBankOld(networkName));
            }
            else
            {
                GestureBankStub stub = new GestureBankStub();
                stub.gestures = new List <Gesture>();
                Debug.Log("GetGestureBank: " + stub.gestures.Count);
                return(stub.gestures);
            }
        }
Beispiel #2
0
        public static void SaveGestureBank(List <Gesture> gestureBank, string networkName)
        {
            GestureBankStub stub = new GestureBankStub();

            stub.gestures = gestureBank;
            string filePath = Application.streamingAssetsPath + Config.NEURAL_NET_PATH + networkName + "/GestureBank.txt";

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(filePath, false))
            {
                //file.WriteLine(dumbString);
                file.WriteLine(JsonUtility.ToJson(stub, true));
            }
#if UNITY_EDITOR
            AssetDatabase.ImportAsset(filePath);
#endif
        }