Ejemplo n.º 1
0
        internal static SukiSchema CreateSchema(SukiSchemaInfo info)
        {
            SukiSchema ret = null;

            switch (info.SchemaMetric)
            {
            case NodeMetric.SingleNodePosition:
                ret = new SingleNodePositionSchema(info);
                break;

            case NodeMetric.SingleJointAngle:
                ret = new SingleJointAngleSchema(info);
                break;

            case NodeMetric.MultiNodeVectorBetween:
                ret = new MultiNodeVectorBetweenSchema(info);
                break;

            case NodeMetric.MultiNodeAngleBetween:
                ret = new MultiNodeAngleBetweenSchema(info);
                break;

            default:
                throw new System.Exception("Invalid Schem Node Metric");
            }
            return(ret);
        }
Ejemplo n.º 2
0
        /*  public void ReadConfigFiles()
         * {
         *    List<string> schemaFiles = SukiSchemaList.Instance.GetAllSchemaFiles();
         *    if (schemaFiles.Count <= 0)
         *    {
         *        //				throw new System.Exception("No Schema Files specified");
         *
         *        print("No Schema Files specified.  Loading default.");
         *        schemaFiles.Add("suki/default.suki.json");
         *    }
         *    foreach (string filename in schemaFiles)
         *        {
         *        Debug.Log("Loading SUKI JSON file: " + filename);
         *        string json = File.ReadAllText(filename);
         *        SukiSchemaInfo newSchemaInfo = SukiSchemaInfo.Deserialize(json);
         *        SukiSchema newSchema = SukiSchema.CreateSchema(newSchemaInfo);
         *        schemas.Add(newSchema);
         *        }
         * }*/


        public void ReadConfigFiles()
        {
            List <string> schemaFiles = SukiSchemaList.Instance.GetAllSchemaFiles();

            if (schemaFiles.Count <= 0)
            {
                print("No Schema Files specified.  Loading default.");
                //                    string defaultSuki = "suki/default.suki";//has to be json, so this doesn't work.
                string defaultSuki = Application.streamingAssetsPath + "/Suki/default.suki";
                SukiSchemaList.Instance.AddFile(defaultSuki);
                schemaFiles = SukiSchemaList.Instance.GetAllSchemaFiles();
                //sukiParam = ((GenericParameter<string>)ParameterHandler.Instance.AllParameters[0].GetParameter(ParameterStrings.SUKI_PARAM_FILE));
            }
            foreach (string filename in schemaFiles)
            {
                Debug.Log("Loading SUKI JSON file: " + filename);
                string json;

                string url;
                url = filename;
                url = url.Replace('\\', '/');
                //#if !UNITY_ANDROID || UNITY_EDITOR
                if (Application.platform != RuntimePlatform.Android)
                {
                    Debug.Log("Not Android Platform: adding file:// to url.");
                    url = "file://" + url;
                }
                //#endif
                string sukitext;
                Debug.Log("suki json url=" + url);
                WWW localFile = GetWWW(url);
                json = localFile.text;
                Debug.Log("sukifile=" + json);


                //json = File.ReadAllText(filename);
                SukiSchemaInfo newSchemaInfo = SukiSchemaInfo.Deserialize(json);
                SukiSchema     newSchema     = SukiSchema.CreateSchema(newSchemaInfo);
                schemas.Add(newSchema);
            }
        }