Пример #1
0
    public void loadMeshAsync(string filename)
    {
        if (currentLoadedARObject != null)
        {
            unloadARObject(currentLoadedARObject);
        }

        Debug.Log("!!! ATTEMPTING TO LOAD MESH");
        using (var assetLoader = new AssetLoaderAsync())
        {
            try
            {
                var assetLoaderOptions = AssetLoaderOptions.CreateInstance();
                //                assetLoaderOptions.RotationAngles = new Vector3(90f, 180f, 0f);
                //              assetLoaderOptions.AutoPlayAnimations = true;

                assetLoaderOptions.Use32BitsIndexFormat = true;
                string filetoload = Application.persistentDataPath + "/" + filename;

                assetLoader.LoadFromFile(filetoload, assetLoaderOptions, null, delegate(GameObject loadedGameObject)
                {
                    //recalculateNormals(loadedGameObject);
                    loadedGameObject.transform.position = Vector3.zero;
                    loadedGameObject.transform.rotation = Quaternion.identity;
                    currentLoadedARObject = loadedGameObject;

                    Debug.Log("!!!!!!!!!**** game object loaded");
                });
            }
            catch (Exception e)
            {
                Debug.LogError(e.ToString());
            }
        }
    }
Пример #2
0
    void TriLib(string path)
    {
        using (var assetLoader = new AssetLoader())
        {
            try
            {
                var assetLoaderOptions = AssetLoaderOptions.CreateInstance();
                assetLoaderOptions.RotationAngles     = new Vector3(0, 180, 0);
                assetLoaderOptions.AutoPlayAnimations = true;
                assetLoaderOptions.UseOriginalPositionRotationAndScale = true;

                var loadedGameObject = assetLoader.LoadFromFile(path, assetLoaderOptions);
                loadedGameObject.transform.position   = new Vector3(0, -1, 0);
                loadedGameObject.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);

                var markerM = Instantiate(MarkerM).transform;
                markerM.name     = "TriLib_Root";
                markerM.position = new Vector3(0, -1, 0);
                markerM.gameObject.AddComponent <SaveSceneTarget>().Path = path;
                loadedGameObject.transform.parent = markerM;

                DandD.SetActive(false);

                LoadCount++;
            }
            catch (Exception e)
            {
                Debug.LogError(e.ToString());
            }
        }
    }
Пример #3
0
 /// <summary>
 /// Setups the Avatar Loader.
 /// </summary>
 protected void Start()
 {
     _loaderOptions = AssetLoaderOptions.CreateInstance();
     _loaderOptions.UseLegacyAnimations = false;
     _loaderOptions.DontGenerateAvatar  = true;
     _loaderOptions.AnimatorController  = RuntimeAnimatorController;
 }
Пример #4
0
            /// <summary>
            /// Gets the asset loader options.
            /// </summary>
            /// <returns>The asset loader options.</returns>
            private AssetLoaderOptions GetAssetLoaderOptions()
            {
                var assetLoaderOptions = AssetLoaderOptions.CreateInstance();

                assetLoaderOptions.DontLoadCameras    = false;
                assetLoaderOptions.DontLoadLights     = false;
                assetLoaderOptions.UseCutoutMaterials = _cutoutToggle.isOn;
                assetLoaderOptions.AddAssetUnloader   = true;
                return(assetLoaderOptions);
            }
Пример #5
0
        public static void Import(string assetPath)
        {
            var assimpLoaderOptions = AssetLoaderOptions.CreateInstance();
            var assetImporter       = AssetImporter.GetAtPath(assetPath);
            var userData            = assetImporter.userData;

            if (!string.IsNullOrEmpty(userData))
            {
                assimpLoaderOptions.Deserialize(userData);
            }
            var folderPath = Path.GetDirectoryName(assetPath);
            var filename   = Path.GetFileName(assetPath);
            var filePath   = folderPath + "/" + filename;
            var prefabPath = filePath + ".prefab";

            using (var assetLoader = new AssetLoader())
            {
                assetLoader.OnMeshCreated              += (meshIndex, mesh) => AddSubAsset(mesh, prefabPath);
                assetLoader.OnMaterialCreated          += (materialIndex, isOverriden, material) => AddSubAsset(material, prefabPath);
                assetLoader.OnTextureLoaded            += (sourcePath, material, propertyName, texture) => AddSubAsset(texture, prefabPath);
                assetLoader.AnimatorControllerCreation += () => AnimatorController.CreateAnimatorControllerAtPath(assetPath + ".controller");
                assetLoader.OnAnimationClipCreated     += (animationClipIndex, animationClip) => AddSubAsset(animationClip, prefabPath);
                assetLoader.OnAvatarCreated            += (avatar, animator) => AddSubAsset(avatar, prefabPath);
                assetLoader.OnObjectLoaded             += delegate(GameObject loadedGameObject)
                {
                    var existingPrefab = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject));
                    if (existingPrefab == null)
                    {
#if UNITY_2018_3_OR_NEWER
                        existingPrefab = PrefabUtility.SaveAsPrefabAsset(loadedGameObject, prefabPath);
#else
                        existingPrefab = PrefabUtility.CreatePrefab(prefabPath, loadedGameObject);
#endif
                    }
                    else
                    {
#if UNITY_2018_3_OR_NEWER
                        existingPrefab = PrefabUtility.SaveAsPrefabAsset(loadedGameObject, prefabPath);
#else
                        PrefabUtility.ReplacePrefab(loadedGameObject, existingPrefab, ReplacePrefabOptions.ReplaceNameBased);
#endif
                    }
                    AssetDatabase.SaveAssets();
                    AssetDatabase.Refresh();
                    Object.DestroyImmediate(loadedGameObject);
                    var activeEditor = TriLibAssetEditor.Active;
                    if (activeEditor != null && activeEditor.AssetPath == assetPath)
                    {
                        activeEditor.OnPrefabCreated((GameObject)existingPrefab);
                    }
                };
                DeleteAllAssets(prefabPath);
                assetLoader.LoadFromFile(assetPath, assimpLoaderOptions);
            }
        }
 private void ImportModel(string path)
 {
     using (var assetLoader = new AssetLoader())
     {
         var assetLoaderOptions = AssetLoaderOptions.CreateInstance();
         assetLoaderOptions.DontLoadLights    = true;
         assetLoaderOptions.DontLoadCameras   = true;
         assetLoaderOptions.DontLoadMaterials = false;
         assetLoader.LoadFromFile(path, assetLoaderOptions, modelViewParent); //Loads the model synchronously and stores the reference in myGameObject.
     }
 }
Пример #7
0
        public static void Import(string assetPath)
        {
            var assimpLoaderOptions = AssetLoaderOptions.CreateInstance();
            var assetImporter       = AssetImporter.GetAtPath(assetPath);
            var userData            = assetImporter.userData;

            if (!string.IsNullOrEmpty(userData))
            {
                assimpLoaderOptions.Deserialize(userData);
            }
            var folderPath   = Path.GetDirectoryName(assetPath);
            var filename     = Path.GetFileName(assetPath);
            var filePath     = folderPath + "/" + filename;
            var prefabPath   = filePath + ".prefab";
            var assimpLoader = new AssetLoader();

            assimpLoader.OnMeshCreated     += (meshIndex, mesh) => ReplaceOldAsset(mesh, prefabPath);
            assimpLoader.OnMaterialCreated += delegate(uint materialIndex, bool isOverriden, Material material)
            {
                if (!isOverriden)
                {
                    ReplaceOldAsset(material, prefabPath);
                }
            };
            assimpLoader.OnTextureLoaded +=
                (sourcePath, material, propertyName, texture) => ReplaceOldAsset(texture, prefabPath);

            assimpLoader.OnAnimationClipCreated +=
                (animationClipIndex, animationClip) => ReplaceOldAsset(animationClip, prefabPath);
            assimpLoader.OnObjectLoaded += delegate(GameObject loadedGameObject)
            {
                var existingPrefab = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject));
                if (existingPrefab == null)
                {
                    existingPrefab = PrefabUtility.CreatePrefab(prefabPath, loadedGameObject);
                }
                else
                {
                    existingPrefab = PrefabUtility.ReplacePrefab(loadedGameObject, existingPrefab,
                                                                 ReplacePrefabOptions.ReplaceNameBased);
                }
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                AssetDatabase.ImportAsset(prefabPath);
                Object.DestroyImmediate(loadedGameObject);
                var activeEditor = TriLibAssetEditor.Active;
                if (activeEditor != null && activeEditor.AssetPath == assetPath)
                {
                    activeEditor.OnPrefabCreated((GameObject)existingPrefab);
                }
            };
            assimpLoader.LoadFromFile(assetPath, assimpLoaderOptions);
        }
Пример #8
0
        private AssetLoaderOptions GetAssetLoaderOptions()
        {
            var assetLoaderOptions = AssetLoaderOptions.CreateInstance();

            assetLoaderOptions.DontLoadCameras = false;
            assetLoaderOptions.DontLoadLights  = false;
            assetLoaderOptions.UseOriginalPositionRotationAndScale = true;
            assetLoaderOptions.DisableAlphaMaterials = true;
            assetLoaderOptions.MaterialShadingMode   = MaterialShadingMode.Standard;
            assetLoaderOptions.AddAssetUnloader      = true;
            assetLoaderOptions.AdvancedConfigs.Add(AssetAdvancedConfig.CreateConfig(AssetAdvancedPropertyClassNames.FBXImportDisableDiffuseFactor, true));
            return(assetLoaderOptions);
        }
Пример #9
0
        private void LoadUserData()
        {
            _tempAssetLoaderOptions = AssetLoaderOptions.CreateInstance();
            _assetImporter          = AssetImporter.GetAtPath(AssetPath);
            var userData = _assetImporter.userData;

            if (!string.IsNullOrEmpty(userData))
            {
                _tempAssetLoaderOptions.Deserialize(userData);
            }
            _tempSerializedObject = new SerializedObject(_tempAssetLoaderOptions);
            _tempSerializedObject.Update();
        }
    void DownloadModel()
    {
        var path = Application.persistentDataPath + "/" + fileName.Replace(" ", "");

        //EditorUtility.RevealInFinder(path);

        //first try to get the file by name
        try
        {
            using (var assetLoader = new AssetLoader())
            {
                var ops = AssetLoaderOptions.CreateInstance();   //Creates the AssetLoaderOptions instance.
                                                                 //AssetLoaderOptions let you specify options to load your model.
                                                                 //(Optional) You can skip this object creation and it's parameter or pass null.

                //You can modify assetLoaderOptions before passing it to LoadFromFile method. You can check the AssetLoaderOptions API reference at:
                //https://ricardoreis.net/trilib/manual/html/class_tri_lib_1_1_asset_loader_options.html
                ops.UseOriginalPositionRotationAndScale = true;
                ops.Scale = 1 / 1000f;

                var wrapperGameObject = gameObject;                                        //Sets the game object where your model will be loaded into.
                                                                                           //(Optional) You can skip this object creation and it's parameter or pass null.

                var myGameObject = assetLoader.LoadFromFile(path, ops, wrapperGameObject); //Loads the model synchronously and stores the reference in myGameObject.


                //successful retreival of file
                if (myGameObject != null)
                {
                    var ObjectToPlace = Instantiate(myGameObject);

                    //After instantiating object kill UI
                    GameObject.Find("Canvas").SetActive(false);

                    //Assign variable to TapToPlace
                    GameObject.Find("AR Session Origin").GetComponent <TapToPlace>().objectToPlace = ObjectToPlace;
                }
            }
        }
        catch
        {
            //if we don't get the file locally, we'll have to download it from the server

            request = GoogleDriveFiles.Download(fileId);

            //request = GoogleDriveFiles.Download(fileId, range.start >= 0 ? (RangeInt?)range : null);
            request.Send().OnDone += SetResult;
        }
    }
Пример #11
0
            /// <summary>
            /// Downloads the model.
            /// </summary>
            /// <returns>Coroutine <see cref="System.Collections.IEnumerator"/></returns>
            private IEnumerator DownloadModel()
            {
                _www = new WWW(ModelURI);
                while (!_www.isDone)
                {
                    yield return(null);
                }
                var fullPath = Application.persistentDataPath + ModelLocalPath;

                File.WriteAllBytes(fullPath, _www.bytes);
                using (var assetLoader = new AssetLoader())
                {
                    var assetLoaderOptions = AssetLoaderOptions.CreateInstance();
                    assetLoaderOptions.Scale = ModelScale;
                    assetLoader.LoadFromFile(fullPath, assetLoaderOptions, gameObject);
                }
            }
Пример #12
0
    void LoadModel(string ModelName)
    {
        model = imageTargetBehaviour.gameObject.transform.Find("Wrapper_RootNode").gameObject;
        using (var assetLoader = new AssetLoader())
        {
            var assetLoaderOptions = AssetLoaderOptions.CreateInstance();
            assetLoaderOptions.AutoPlayAnimations = true;
            assetLoaderOptions.Scale = 1f;
            GameObject _rootGameObject = assetLoader.LoadFromFile(Application.persistentDataPath + "/" + ModelName, assetLoaderOptions, model);

            _rootGameObject.transform.localScale       = new Vector3(1, 1, 1);
            _rootGameObject.transform.localPosition    = new Vector3(0, 0, 0);
            _rootGameObject.transform.localEulerAngles = new Vector3(0, 180, 0);
            _rootGameObject.transform.parent           = Camera.main.transform;
            _rootGameObject.transform.localScale       = new Vector3(5, 5, 5);
            _rootGameObject.transform.localPosition    = new Vector3(0, -3, 100);
        }
    }
Пример #13
0
 /// <summary>
 /// Tries to load "Bouncing.fbx" model
 /// </summary>
 protected void Start()
 {
     using (var assetLoader = new AssetLoader())
     {
         try
         {
             var assetLoaderOptions = AssetLoaderOptions.CreateInstance();
             assetLoaderOptions.RotationAngles     = new Vector3(90f, 180f, 0f);
             assetLoaderOptions.AutoPlayAnimations = true;
             var loadedGameObject = assetLoader.LoadFromFile(Application.dataPath + "/TriLib/TriLib/Samples/Models/Bouncing.fbx", assetLoaderOptions);
             loadedGameObject.transform.position = new Vector3(128f, 0f, 0f);
         }
         catch (Exception e)
         {
             Debug.LogError(e.ToString());
         }
     }
 }
Пример #14
0
    public void SetViewModel(Dropdown dropdown)
    {
        int index = dropdown.value + 1;

        if (!modelURI.ContainsKey(index))
        {
            Debug.LogWarning("Model with key " + index.ToString() + " does not exist.");
        }

        var assetLoaderOptions = AssetLoaderOptions.CreateInstance();

        assetLoaderOptions.DontLoadCameras    = false;
        assetLoaderOptions.DontLoadLights     = false;
        assetLoaderOptions.UseCutoutMaterials = true;
        assetLoaderOptions.AddAssetUnloader   = true;

        assetDownloader.DownloadAsset(modelURI[index], ".zip", OnAssetDownloaded, null, assetLoaderOptions, m_platformPivot);
    }
Пример #15
0
    void testasync()
    {
        using (var assetLoaderAsync = new AssetLoaderAsync())
        {
            var assetLoaderOptions = AssetLoaderOptions.CreateInstance();   //Creates the AssetLoaderOptions instance.
                                                                            //AssetLoaderOptions let you specify options to load your model.
                                                                            //(Optional) You can skip this object creation and it's parameter or pass null.

            //You can modify assetLoaderOptions before passing it to LoadFromFile method. You can check the AssetLoaderOptions API reference at:
            //https://ricardoreis.net/trilib/manual/html/class_tri_lib_1_1_asset_loader_options.html

            var wrapperGameObject = gameObject;                             //Sets the game object where your model will be loaded into.
                                                                            //(Optional) You can skip this object creation and it's parameter or pass null.

            var thread = assetLoaderAsync.LoadFromFile("PATH TO MY FILE.FBX", assetLoaderOptions, wrapperGameObject, delegate(GameObject myGameObject) {
                //Here you can get the reference to the loaded model using myGameObject.
            }); //Loads the model asynchronously and returns the reference to the created Task/Thread.
        }
    }
Пример #16
0
 /// <summary>
 /// Tries to load "Bouncing.fbx" model
 /// </summary>
 protected void Start()
 {
     using (var assetLoader = new AssetLoader())
     {
         try
         {
             var assetLoaderOptions = AssetLoaderOptions.CreateInstance();
             //assetLoaderOptions.RotationAngles = new Vector3(90f, 180f, 0f);
             assetLoaderOptions.AutoPlayAnimations = true;
             // assetLoaderOptions.UseOriginalPositionRotationAndScale = true;
             var loadedGameObject = assetLoader.LoadFromFile(string.Format("{0}/Bouncing.fbx", TriLibProjectUtils.FindPathRelativeToProject("Models", "t:Model Bouncing")), assetLoaderOptions);
             //   loadedGameObject.transform.position = new Vector3(128f, 0f, 0f);
         }
         catch (Exception e)
         {
             Debug.LogError(e.ToString());
         }
     }
 }
Пример #17
0
            /// <summary>
            /// Gets the asset loader options.
            /// </summary>
            /// <returns>The asset loader options.</returns>
            private AssetLoaderOptions GetAssetLoaderOptions()
            {
                var assetLoaderOptions = AssetLoaderOptions.CreateInstance();

                assetLoaderOptions.DontLoadCameras = false;
                assetLoaderOptions.DontLoadLights  = false;
                assetLoaderOptions.UseOriginalPositionRotationAndScale = true;
                switch (_transparencyModeDropdown.value)
                {
                case 0:
                    assetLoaderOptions.DisableAlphaMaterials = true;
                    break;

                case 1:
                    assetLoaderOptions.MaterialTransparencyMode = MaterialTransparencyMode.Alpha;
                    break;

                case 2:
                    assetLoaderOptions.MaterialTransparencyMode = MaterialTransparencyMode.Cutout;
                    break;

                case 3:
                    assetLoaderOptions.MaterialTransparencyMode = MaterialTransparencyMode.Fade;
                    break;
                }
                switch (_shadingDropdown.value)
                {
                case 1:
                    assetLoaderOptions.MaterialShadingMode = MaterialShadingMode.Roughness;
                    break;

                case 2:
                    assetLoaderOptions.MaterialShadingMode = MaterialShadingMode.Specular;
                    break;
                }
                assetLoaderOptions.AddAssetUnloader = true;
                assetLoaderOptions.AdvancedConfigs.Add(AssetAdvancedConfig.CreateConfig(AssetAdvancedPropertyClassNames.FBXImportDisableDiffuseFactor, true));
                return(assetLoaderOptions);
            }
    private void SetResult(UnityGoogleDrive.Data.File file)
    {
        result = Encoding.UTF8.GetString(file.Content);
        var path = Application.persistentDataPath + "/" + fileName.Replace(" ", "");

        File.WriteAllBytes(path, file.Content);

        //Assign the file to the placement object
        //successful retreival of file
        using (var assetLoader = new AssetLoader())
        {
            var ops = AssetLoaderOptions.CreateInstance();   //Creates the AssetLoaderOptions instance.
                                                             //AssetLoaderOptions let you specify options to load your model.
                                                             //(Optional) You can skip this object creation and it's parameter or pass null.

            //You can modify assetLoaderOptions before passing it to LoadFromFile method. You can check the AssetLoaderOptions API reference at:
            //https://ricardoreis.net/trilib/manual/html/class_tri_lib_1_1_asset_loader_options.html
            ops.UseOriginalPositionRotationAndScale = true;
            ops.Scale = 1 / 1000f;

            var wrapperGameObject = gameObject;                                         //Sets the game object where your model will be loaded into.
                                                                                        //(Optional) You can skip this object creation and it's parameter or pass null.

            var myGameObject  = assetLoader.LoadFromFile(path, ops, wrapperGameObject); //Loads the model synchronously and stores the reference in myGameObject.
            var ObjectToPlace = Instantiate(myGameObject);

            if (ObjectToPlace != null)
            {
                //After instantiating object kill UI
                GameObject.Find("Canvas").SetActive(false);

                //Assign variable to TapToPlace
                GameObject.Find("AR Session Origin").GetComponent <TapToPlace>().objectToPlace = ObjectToPlace;
            }
        }


        //EditorUtility.RevealInFinder(path);
    }
Пример #19
0
            /// <summary>
            /// Tries to load "Bouncing.fbx" model
            /// </summary>
            protected void Start()
            {
                using (var assetLoader = new AssetLoader())
                {
                    try
                    {
                        var assetLoaderOptions = AssetLoaderOptions.CreateInstance();
                        assetLoaderOptions.RotationAngles     = new Vector3(0f, 0f, 0f);
                        assetLoaderOptions.AutoPlayAnimations = true;
                        //Use this for PC
                        //var loadedGameObject = assetLoader.LoadFromFile("C:/Users/felix/Desktop/bird.OBJ", assetLoaderOptions);  //This can be a .fbx file or a .obj file

                        //ask for permission
                        //Use this for Android
                        GameObject loadedGameObject = assetLoader.LoadFromFile("storage/emulated/0/Download/bird.OBJ", assetLoaderOptions);  //This can be a .fbx file or a .obj file
                        //Inventory.addItem(loadedGameObject);
                        loadedGameObject.transform.position = new Vector3(0f, 0f, 0f);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e.ToString());
                    }
                }
            }
Пример #20
0
    public bool ImportMap()
    {
        const string mapFilePath = "map.fbx";

        if (!File.Exists(mapFilePath))
        {
            return(false);
        }

        var assetLoader        = new AssetLoader();
        var assetLoaderOptions = AssetLoaderOptions.CreateInstance();

        assetLoaderOptions.RotationAngles        = new Vector3(0f, 0f, 0f);
        assetLoaderOptions.DontLoadAnimations    = true;
        assetLoaderOptions.DontLoadMaterials     = true;
        assetLoaderOptions.DontLoadCameras       = true;
        assetLoaderOptions.GenerateMeshColliders = true;

        Map = assetLoader.LoadFromFile(mapFilePath, assetLoaderOptions);
        Map.transform.position = new Vector3(0f, 0f, 0f);
        Map.name = "Map";
        SetMap();
        return(true);
    }
    // Modified version of ImportTrainFile for importing nn file
    void ImportClassifyFile(string directory, string fileName, int fileIndex, string modelName, List <string> recordingLabels, string[] jointNames)
    //void ImportFile(string directory, string fileName, int fileIndex, string[] jointNames)
    {
        string filePath           = directory + "/" + fileName;
        var    assetLoader        = new AssetLoader();
        var    assetLoaderOptions = AssetLoaderOptions.CreateInstance();

        assetLoaderOptions.AutoPlayAnimations = true;
        assetLoaderOptions.AnimationWrapMode  = WrapMode.Loop;
        assetLoaderOptions.UseOriginalPositionRotationAndScale = true;

        //Debug.Log("filename: " + fileName);
        string recordingName = fileName.Replace(".fbx", "");

        //Debug.Log("recordingName: " + recordingName);

        _rootGameObject      = assetLoader.LoadFromFileWithTextures(filePath, assetLoaderOptions);
        _rootGameObject.name = recordingName;
        _rootGameObject.transform.localScale = new Vector3(0.005f, 0.005f, 0.005f);
        _rootGameObject.transform.parent     = transform;


        _rootGameObject.AddComponent <JointVisualizer>();

        _rootGameObject.AddComponent <BehaviorParameters>();
        // all the behavior parameters has to be here and not in the Agent Init in order for it to work for some reason. i haven't been able to figure out why that might be, but who cares?
        _rootGameObject.GetComponent <BehaviorParameters>().BehaviorName = "MotionCaptureRNN";
        _rootGameObject.GetComponent <BehaviorParameters>().BrainParameters.VectorObservationSize = jointNames.Length * 4 + 3; // number of joints times 4 quaternion values per joint, plus 3 position values for the hips
        _rootGameObject.GetComponent <BehaviorParameters>().BrainParameters.VectorActionSpaceType = SpaceType.Discrete;

        // Add nn file
        NNModel model = new NNModel();

        model.modelData       = new NNModelData();
        model.modelData.Value = File.ReadAllBytes(Application.streamingAssetsPath + "/results/testName/MotionCaptureRNN.nn");
        _rootGameObject.GetComponent <BehaviorParameters>().Model = model;


        // The commented out line will work when we have a data structure for features working
        List <string> modelLabels      = dataManager.GetLabelsFromModel(modelName);
        int           numLabelsInModel = modelLabels.Count;

        _rootGameObject.GetComponent <BehaviorParameters>().BrainParameters.VectorActionSize = new int[numLabelsInModel];
        //_rootGameObject.GetComponent<BehaviorParameters>().BrainParameters.VectorActionSize = new int[2]; // this will need to be changed to match the features list

        // For now, we're using a vectoractionsize value of 2 for each vector action.
        // Because we're using binary labels that are either true or false.  Ie.It either is labeled "twisting" or it's not.
        for (int i = 0; i < _rootGameObject.GetComponent <BehaviorParameters>().BrainParameters.VectorActionSize.Length; i++)
        {
            _rootGameObject.GetComponent <BehaviorParameters>().BrainParameters.VectorActionSize[i] = 2;
        }

        int[] recordingVectorActionValues = new int[numLabelsInModel];
        for (int i = 0; i < recordingVectorActionValues.Length; i++)
        {
            // We need to make the list of labels for this recording conform to array of all the possible labels for the model
            // where the value at each index corresponds to whether that label is present for this model.
            // For example, if the possible labels are:  Arc, Twist, Bend
            // and this recording has the labels: Arc, Bend
            // then we need an array like {1, 0, 1}
            if (recordingLabels.Contains(modelLabels[i])) // it should be safe to use i here because the size of the recordingVectorActionValues arary should be the same length as the modelFeatures array, because it was set above
            {
                recordingVectorActionValues[i] = 1;
                //_rootGameObject.GetComponent<BehaviorParameters>().BrainParameters.VectorActionSize[i] = 1;
            }
            else
            {
                recordingVectorActionValues[i] = 0;
                // _rootGameObject.GetComponent<BehaviorParameters>().BrainParameters.VectorActionSize[i] = 0;
            }
        }



        //Debug.Log("adding agent component");
        _rootGameObject.AddComponent <MocapTrainerAgent_TimedEpisode_RuntimeVersion>();
        //Debug.Log("calling init on agent component");
        _rootGameObject.GetComponent <MocapTrainerAgent_TimedEpisode_RuntimeVersion>().Init(
            recordingName,
            jointNames,
            behaviorName,
            recordingVectorActionValues
            );
    }
Пример #22
0
    public static GameObject load(String assetLocation)
    {
        GameObject g = null;

        using (var assetLoader = new AssetLoader())
        {
            try
            {
                var assetLoaderOptions = AssetLoaderOptions.CreateInstance();
                assetLoaderOptions.RotationAngles = Vector3.zero;
                GameObject loadedGameObject = assetLoader.LoadFromFile(@"./" + assetLocation, assetLoaderOptions, null, null);

                g = loadedGameObject;

                // First lets find the size of the model
                SizeBoundingBox.CreateBox(g.transform);
                var box = g.GetComponent <BoxCollider>();
                if (Vector3.Scale(box.size, g.transform.localScale).x > maxSize)
                {
                    g.transform.localScale *= maxSize / Vector3.Scale(box.size, g.transform.localScale).x;
                }
                if (Vector3.Scale(box.size, g.transform.localScale).y > maxSize)
                {
                    g.transform.localScale *= maxSize / Vector3.Scale(box.size, g.transform.localScale).y;
                }
                if (Vector3.Scale(box.size, g.transform.localScale).z > maxSize)
                {
                    g.transform.localScale *= maxSize / Vector3.Scale(box.size, g.transform.localScale).z;
                }
                else
                {
                    if (Vector3.Scale(box.size, g.transform.localScale).x < minSize)
                    {
                        g.transform.localScale *= minSize / Vector3.Scale(box.size, g.transform.localScale).x;
                    }
                    if (Vector3.Scale(box.size, g.transform.localScale).y < minSize)
                    {
                        g.transform.localScale *= minSize / Vector3.Scale(box.size, g.transform.localScale).y;
                    }
                    if (Vector3.Scale(box.size, g.transform.localScale).z < minSize)
                    {
                        g.transform.localScale *= minSize / Vector3.Scale(box.size, g.transform.localScale).z;
                    }
                }
                g.transform.Rotate(90, 0, 0);

                var rs = g.transform.GetComponentsInChildren <Renderer>();
                foreach (Renderer r in rs)
                {
                    if (r?.materials?.Any() == true)
                    {
                        foreach (Material mat in r.materials)
                        {
                            mat.EnableKeyword("_GLOSSYREFLECTIONS_OFF");
                        }
                    }
                }
                box.enabled = false;
                g.SetActive(false);
            }
            catch (Exception e)
            {
                Debug.LogError(e.ToString());
            }
        }
        return(g);
    }
        public override void OnInspectorGUI()
        {
            if (!_isAssimpAsset)
            {
                base.OnInspectorGUI();
                return;
            }
            GUI.enabled = true;
#pragma warning disable 618
            EditorGUIUtility.LookLikeInspector();
#pragma warning restore 618
            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal();
            _currentTab = GUILayout.Toggle(_currentTab == 0, "General", "Button") ? 0 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 1, "Meshes", "Button") ? 1 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 2, "Materials", "Button") ? 2 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 3, "Animations", "Button") ? 3 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 4, "Advanced", "Button") ? 4 : _currentTab;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUI.BeginChangeCheck();
            switch (_currentTab)
            {
            case 0:
                EditorGUILayout.LabelField("General", EditorStyles.boldLabel);
                _tempAssetLoaderOptions.PostProcessSteps = (AssimpPostProcessSteps)EditorGUILayout.EnumMaskField("Post Processor Options", _tempAssetLoaderOptions.PostProcessSteps);
                break;

            case 1:
            {
                EditorGUILayout.LabelField("Meshes", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("Scale"));
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("RotationAngles"));
                var generateMeshCollidersProperty = _tempSerializedObject.FindProperty("GenerateMeshColliders");
                EditorGUILayout.PropertyField(generateMeshCollidersProperty);
                if (generateMeshCollidersProperty.boolValue)
                {
                    EditorGUI.indentLevel = 1;
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ConvexMeshColliders"));
                    EditorGUI.indentLevel = 0;
                }
            }
            break;

            case 2:
            {
                EditorGUILayout.LabelField("Materials", EditorStyles.boldLabel);
                var dontLoadMaterialsProperty = _tempSerializedObject.FindProperty("DontLoadMaterials");
                EditorGUILayout.PropertyField(dontLoadMaterialsProperty);
                if (!dontLoadMaterialsProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("TexturesPathOverride"));
                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("MaterialsOverride"), new GUIContent("Material Override"), true);
                }
            }
            break;

            case 3:
            {
                EditorGUILayout.LabelField("Animations", EditorStyles.boldLabel);

                var dontLoadAnimationsProperty = _tempSerializedObject.FindProperty("DontLoadAnimations");
                EditorGUILayout.PropertyField(dontLoadAnimationsProperty);
                if (!dontLoadAnimationsProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AutoPlayAnimations"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AnimationWrapMode"));
                    var legacyAnimationProperty = _tempSerializedObject.FindProperty("UseLegacyAnimations");
                    EditorGUILayout.PropertyField(legacyAnimationProperty);
                    if (!legacyAnimationProperty.boolValue)
                    {
                        EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AnimatorController"));
                    }
                }
            }
            break;

            default:
            {
                EditorGUILayout.LabelField("Advanced", EditorStyles.boldLabel);
                var advancedConfigs = _tempSerializedObject.FindProperty("AdvancedConfigs");
                var lastGroup       = string.Empty;
                var groupIndex      = 0;
                foreach (var configKey in AssetAdvancedPropertyMetadata.ConfigKeys)
                {
                    AssetAdvancedConfigType assetAdvancedConfigType;
                    string className;
                    string description;
                    string @group;
                    bool   hasDefaultValue;
                    bool   hasMinValue;
                    bool   hasMaxValue;
                    object defaultValue;
                    object minValue;
                    object maxValue;
                    AssetAdvancedPropertyMetadata.GetOptionMetadata(configKey, out assetAdvancedConfigType, out className, out description, out @group, out defaultValue, out minValue, out maxValue, out hasDefaultValue, out hasMinValue, out hasMaxValue);
                    SerializedProperty elementSerializedProperty = null;
                    var serializedElementIndex = 0;
                    var recentlyCreated        = false;
                    for (var i = 0; i < _tempAssetLoaderOptions.AdvancedConfigs.Count; i++)
                    {
                        var advancedProperty = _tempAssetLoaderOptions.AdvancedConfigs[i];
                        if (advancedProperty.Key == configKey)
                        {
                            serializedElementIndex    = i;
                            elementSerializedProperty = advancedConfigs.GetArrayElementAtIndex(i);
                            break;
                        }
                    }
                    if (@group != lastGroup)
                    {
                        lastGroup = @group;
                        _groupUnfolded[groupIndex] = EditorGUILayout.Foldout(_groupUnfolded[groupIndex], lastGroup);
                        groupIndex++;
                    }
                    if (_groupUnfolded[groupIndex - 1])
                    {
                        EditorGUILayout.BeginHorizontal();
                        var enableProperty = EditorGUILayout.BeginToggleGroup(new GUIContent(className, description), elementSerializedProperty != null);
                        if (elementSerializedProperty == null && enableProperty)
                        {
                            advancedConfigs.InsertArrayElementAtIndex(advancedConfigs.arraySize);
                            _tempSerializedObject.ApplyModifiedProperties();
                            var elementIndex = Mathf.Max(0, advancedConfigs.arraySize - 1);
                            elementSerializedProperty = advancedConfigs.GetArrayElementAtIndex(elementIndex);
                            elementSerializedProperty.FindPropertyRelative("Key").stringValue = configKey;
                            _tempSerializedObject.ApplyModifiedProperties();
                            recentlyCreated = true;
                        }
                        else if (elementSerializedProperty != null && !enableProperty)
                        {
                            advancedConfigs.DeleteArrayElementAtIndex(serializedElementIndex);
                            _tempSerializedObject.ApplyModifiedProperties();
                            return;
                        }
                        SerializedProperty valueSerializedProperty;
                        switch (assetAdvancedConfigType)
                        {
                        case AssetAdvancedConfigType.Bool:
                            var boolDefaultValue = hasDefaultValue && (bool)defaultValue;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.Toggle(boolDefaultValue ? "Enabled" : "Disabled", boolDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("BoolValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.boolValue = boolDefaultValue;
                                }
                                EditorGUILayout.PropertyField(valueSerializedProperty, new GUIContent(valueSerializedProperty.boolValue ? "Enabled" : "Disabled"));
                            }
                            break;

                        case AssetAdvancedConfigType.Integer:
                            var intDefaultValue = hasDefaultValue ? (int)defaultValue : 0;
                            if (hasMinValue && hasMaxValue)
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.IntSlider(intDefaultValue, (int)minValue, (int)maxValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.intValue = intDefaultValue;
                                    }
                                    EditorGUILayout.IntSlider(valueSerializedProperty, (int)minValue, (int)maxValue, GUIContent.none);
                                }
                            }
                            else
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.IntField(intDefaultValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.intValue = intDefaultValue;
                                    }
                                    EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none);
                                }
                            }
                            break;

                        case AssetAdvancedConfigType.Float:
                            var floatDefaultValue = hasDefaultValue ? (float)defaultValue : 0f;
                            if (hasMinValue && hasMaxValue)
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.Slider(floatDefaultValue, (float)minValue, (float)maxValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("FloatValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.floatValue = floatDefaultValue;
                                    }
                                    EditorGUILayout.Slider(valueSerializedProperty, (float)minValue, (float)maxValue, GUIContent.none);
                                }
                            }
                            else
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.FloatField(floatDefaultValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("FloatValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.floatValue = floatDefaultValue;
                                    }
                                    EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none);
                                }
                            }
                            break;

                        case AssetAdvancedConfigType.String:
                            var stringDefaultValue = hasDefaultValue ? (string)defaultValue : string.Empty;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.TextField(stringDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("StringValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.stringValue = stringDefaultValue;
                                }
                                EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiComponent:
                            var aiComponentDefaultValue = hasDefaultValue ? (AiComponent)defaultValue : AiComponent.Animations;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.EnumMaskField(aiComponentDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.intValue = (int)aiComponentDefaultValue;
                                }
                                PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiPrimitiveType:
                            var aiPrimitiveTypeDefaultValue = hasDefaultValue ? (AiPrimitiveType)defaultValue : AiPrimitiveType.Line;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.EnumMaskField(aiPrimitiveTypeDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.intValue = (int)aiPrimitiveTypeDefaultValue;
                                }
                                PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiUVTransform:
                            var aiUvTransformDefaultValue = hasDefaultValue ? (AiUVTransform)defaultValue : AiUVTransform.Rotation;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.EnumMaskField(aiUvTransformDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.intValue = (int)aiUvTransformDefaultValue;
                                }
                                PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none);
                            }
                            break;
                        }
                        GUI.enabled = true;
                        EditorGUILayout.EndToggleGroup();
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            break;
            }
            if (EditorGUI.EndChangeCheck())
            {
                _hasChanged = true;
            }
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUI.enabled = _hasChanged;
            if (GUILayout.Button("Revert"))
            {
                DestroyTempObject();
                _tempAssetLoaderOptions = AssetLoaderOptions.CreateInstance();
                SaveChanges();
            }
            if (GUILayout.Button("Apply"))
            {
                _tempSerializedObject.ApplyModifiedProperties();
                SaveChanges();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }
Пример #24
0
            /// <summary>
            /// Handles "Load asset button" click event and tries to load an asset at chosen path.
            /// </summary>
            private void LoadAssetButtonClick()
            {
                var fileOpenDialog = FileOpenDialog.Instance;

                fileOpenDialog.Title  = "Please select a File";
                fileOpenDialog.Filter = AssetLoader.GetSupportedFileExtensions();
#if (UNITY_WINRT && !UNITY_EDITOR_WIN)
                fileOpenDialog.ShowFileOpenDialog(delegate(byte[] fileBytes, string filename)
#else
                fileOpenDialog.ShowFileOpenDialog(delegate(string filename)
#endif
                {
                    HideControls();
                    if (_rootGameObject != null)
                    {
                        Destroy(_rootGameObject);
                        _rootGameObject = null;
                    }
                    var assetLoaderOptions             = AssetLoaderOptions.CreateInstance();
                    assetLoaderOptions.DontLoadCameras = false;
                    assetLoaderOptions.DontLoadLights  = false;
                    using (var assimpLoader = new AssetLoader())
                    {
                        try
                        {
#if (UNITY_WINRT && !UNITY_EDITOR_WIN)
                            _rootGameObject = assimpLoader.LoadFromMemory(fileBytes, filename, assetLoaderOptions);
#else
                            _rootGameObject = assimpLoader.LoadFromFile(filename, assetLoaderOptions);
#endif
                        }
                        catch (System.Exception exception)
                        {
                            ErrorDialog.Instance.ShowDialog(exception.ToString());
                        }
                    }
                    if (_rootGameObject != null)
                    {
                        var mainCamera = Camera.main;
                        mainCamera.FitToBounds(_rootGameObject.transform, 3f);
                        _backgroundCanvas.planeDistance = mainCamera.farClipPlane * 0.99f;
                        _spinningText.gameObject.SetActive(true);
                        _spinXToggle.isOn = false;
                        _spinXToggle.gameObject.SetActive(true);
                        _spinYToggle.isOn = false;
                        _spinYToggle.gameObject.SetActive(true);
                        _resetRotationButton.gameObject.SetActive(true);
                        DestroyItems();
                        var rootAnimation = _rootGameObject.GetComponent <Animation>();
                        if (rootAnimation != null)
                        {
                            _animationsText.gameObject.SetActive(true);
                            _animationsScrollRect.gameObject.SetActive(true);
                            _stopAnimationButton.gameObject.SetActive(true);
                            _stopAnimationButton.interactable = false;
                            foreach (AnimationState animationState in rootAnimation)
                            {
                                CreateItem(animationState.name);
                            }
                        }
                    }
                }
                                                  );
            }
Пример #25
0
        public override void OnInspectorGUI()
        {
            if (!_isAssimpAsset)
            {
                base.OnInspectorGUI();
                return;
            }
            GUI.enabled = true;
#pragma warning disable 618
            EditorGUIUtility.LookLikeInspector();
#pragma warning restore 618
            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal();
            _currentTab = GUILayout.Toggle(_currentTab == 0, "General", "Button") ? 0 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 1, "Meshes", "Button") ? 1 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 2, "Materials", "Button") ? 2 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 3, "Animations", "Button") ? 3 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 4, "Misc", "Button") ? 4 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 5, "Metadata", "Button") ? 5 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 6, "Advanced", "Button") ? 6 : _currentTab;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUI.BeginChangeCheck();
            switch (_currentTab)
            {
            case 0:
                EditorGUILayout.LabelField("General", EditorStyles.boldLabel);
#if UNITY_2017_3_OR_NEWER
                _tempAssetLoaderOptions.PostProcessSteps = (AssimpPostProcessSteps)EditorGUILayout.EnumFlagsField("Post Processor Options", _tempAssetLoaderOptions.PostProcessSteps);
#else
                _tempAssetLoaderOptions.PostProcessSteps = (AssimpPostProcessSteps)EditorGUILayout.EnumMaskField("Post Processor Options", _tempAssetLoaderOptions.PostProcessSteps);
#endif
                break;

            case 1:
            {
                EditorGUILayout.LabelField("Meshes", EditorStyles.boldLabel);
                var dontLoadMeshesProperty = _tempSerializedObject.FindProperty("DontLoadMeshes");
                EditorGUILayout.PropertyField(dontLoadMeshesProperty);
                if (!dontLoadMeshesProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("CombineMeshes"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("Scale"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("RotationAngles"));
#if UNITY_2017_3_OR_NEWER
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("Use32BitsIndexFormat"));
#endif
                    var generateMeshCollidersProperty = _tempSerializedObject.FindProperty("GenerateMeshColliders");
                    EditorGUILayout.PropertyField(generateMeshCollidersProperty);
                    if (generateMeshCollidersProperty.boolValue)
                    {
                        EditorGUI.indentLevel = 1;
                        EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ConvexMeshColliders"));
                        EditorGUI.indentLevel = 0;
                    }
                }
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadSkinning"));
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadBlendShapes"));
            }
            break;

            case 2:
            {
                EditorGUILayout.LabelField("Materials", EditorStyles.boldLabel);
                var dontLoadMaterialsProperty = _tempSerializedObject.FindProperty("DontLoadMaterials");
                EditorGUILayout.PropertyField(dontLoadMaterialsProperty);
                if (!dontLoadMaterialsProperty.boolValue)
                {
                    var disableAlphaMaterials = _tempSerializedObject.FindProperty("DisableAlphaMaterials");
                    EditorGUILayout.PropertyField(disableAlphaMaterials);
                    if (!disableAlphaMaterials.boolValue)
                    {
                        EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyColorAlpha"));
                    }
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyDiffuseColor"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyEmissionColor"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplySpecularColor"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyDiffuseTexture"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyEmissionTexture"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplySpecularTexture"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyNormalTexture"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyDisplacementTexture"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyNormalScale"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyGlossiness"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyGlossinessScale"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("GenerateMipMaps"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("UseStandardSpecularMaterial"));
                    if (!disableAlphaMaterials.boolValue)
                    {
                        EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ScanForAlphaMaterials"));
                        EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("UseCutoutMaterials"));
                    }
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("TextureCompression"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("TextureFilterMode"));
                }
            }
            break;

            case 3:
            {
                EditorGUILayout.LabelField("Animations", EditorStyles.boldLabel);
                var dontLoadAnimationsProperty = _tempSerializedObject.FindProperty("DontLoadAnimations");
                EditorGUILayout.PropertyField(dontLoadAnimationsProperty);
                if (!dontLoadAnimationsProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AutoPlayAnimations"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AnimationWrapMode"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("EnsureQuaternionContinuity"));
                    var legacyAnimationProperty = _tempSerializedObject.FindProperty("UseLegacyAnimations");
                    EditorGUILayout.PropertyField(legacyAnimationProperty);
                    if (!legacyAnimationProperty.boolValue)
                    {
                        EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AnimatorController"));
                        var avatar = _tempSerializedObject.FindProperty("Avatar");
                        EditorGUILayout.PropertyField(avatar);
                        if (avatar.objectReferenceValue == null)
                        {
                            EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontGenerateAvatar"));
                        }
                    }
                }
            }
            break;

            case 4:
            {
                EditorGUILayout.LabelField("Misc", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AddAssetUnloader"));
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadCameras"));
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadLights"));
            }
            break;

            case 5:
            {
                EditorGUILayout.LabelField("Metadata", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadMetadata"));
            }
            break;

            default:
            {
                EditorGUILayout.LabelField("Advanced", EditorStyles.boldLabel);
                var advancedConfigs = _tempSerializedObject.FindProperty("AdvancedConfigs");
                var lastGroup       = string.Empty;
                var groupIndex      = 0;
                foreach (var configKey in AssetAdvancedPropertyMetadata.ConfigKeys)
                {
                    AssetAdvancedConfigType assetAdvancedConfigType;
                    string className;
                    string description;
                    string group;
                    bool   hasDefaultValue;
                    bool   hasMinValue;
                    bool   hasMaxValue;
                    object defaultValue;
                    object minValue;
                    object maxValue;
                    AssetAdvancedPropertyMetadata.GetOptionMetadata(configKey, out assetAdvancedConfigType, out className, out description, out group, out defaultValue, out minValue, out maxValue, out hasDefaultValue, out hasMinValue, out hasMaxValue);
                    SerializedProperty elementSerializedProperty = null;
                    var serializedElementIndex = 0;
                    var recentlyCreated        = false;
                    for (var i = 0; i < _tempAssetLoaderOptions.AdvancedConfigs.Count; i++)
                    {
                        var advancedProperty = _tempAssetLoaderOptions.AdvancedConfigs[i];
                        if (advancedProperty.Key == configKey)
                        {
                            serializedElementIndex    = i;
                            elementSerializedProperty = advancedConfigs.GetArrayElementAtIndex(i);
                            break;
                        }
                    }
                    if (group != lastGroup)
                    {
                        lastGroup = group;
                        _groupUnfolded[groupIndex] = EditorGUILayout.Foldout(_groupUnfolded[groupIndex], lastGroup);
                        groupIndex++;
                    }
                    if (_groupUnfolded[groupIndex - 1])
                    {
                        EditorGUILayout.BeginHorizontal();
                        var enableProperty = EditorGUILayout.BeginToggleGroup(new GUIContent(className, description), elementSerializedProperty != null);
                        if (elementSerializedProperty == null && enableProperty)
                        {
                            advancedConfigs.InsertArrayElementAtIndex(advancedConfigs.arraySize);
                            _tempSerializedObject.ApplyModifiedProperties();
                            var elementIndex = Mathf.Max(0, advancedConfigs.arraySize - 1);
                            elementSerializedProperty = advancedConfigs.GetArrayElementAtIndex(elementIndex);
                            elementSerializedProperty.FindPropertyRelative("Key").stringValue = configKey;
                            _tempSerializedObject.ApplyModifiedProperties();
                            recentlyCreated = true;
                        }
                        else if (elementSerializedProperty != null && !enableProperty)
                        {
                            advancedConfigs.DeleteArrayElementAtIndex(serializedElementIndex);
                            _tempSerializedObject.ApplyModifiedProperties();
                            return;
                        }
                        SerializedProperty valueSerializedProperty;
                        switch (assetAdvancedConfigType)
                        {
                        case AssetAdvancedConfigType.Bool:
                            var boolDefaultValue = hasDefaultValue && (bool)defaultValue;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.Toggle(boolDefaultValue ? "Enabled" : "Disabled", boolDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("BoolValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.boolValue = boolDefaultValue;
                                }
                                EditorGUILayout.PropertyField(valueSerializedProperty, new GUIContent(valueSerializedProperty.boolValue ? "Enabled" : "Disabled"));
                            }
                            break;

                        case AssetAdvancedConfigType.Integer:
                            var intDefaultValue = hasDefaultValue ? (int)defaultValue : 0;
                            if (hasMinValue && hasMaxValue)
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.IntSlider(intDefaultValue, (int)minValue, (int)maxValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.intValue = intDefaultValue;
                                    }
                                    EditorGUILayout.IntSlider(valueSerializedProperty, (int)minValue, (int)maxValue, GUIContent.none);
                                }
                            }
                            else
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.IntField(intDefaultValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.intValue = intDefaultValue;
                                    }
                                    EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none);
                                }
                            }
                            break;

                        case AssetAdvancedConfigType.Float:
                            var floatDefaultValue = hasDefaultValue ? (float)defaultValue : 0f;
                            if (hasMinValue && hasMaxValue)
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.Slider(floatDefaultValue, (float)minValue, (float)maxValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("FloatValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.floatValue = floatDefaultValue;
                                    }
                                    EditorGUILayout.Slider(valueSerializedProperty, (float)minValue, (float)maxValue, GUIContent.none);
                                }
                            }
                            else
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.FloatField(floatDefaultValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("FloatValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.floatValue = floatDefaultValue;
                                    }
                                    EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none);
                                }
                            }
                            break;

                        case AssetAdvancedConfigType.String:
                            var stringDefaultValue = hasDefaultValue ? (string)defaultValue : string.Empty;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.TextField(stringDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("StringValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.stringValue = stringDefaultValue;
                                }
                                EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiComponent:
                            var aiComponentDefaultValue = hasDefaultValue ? (AiComponent)defaultValue : AiComponent.Animations;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
#if UNITY_2017_3_OR_NEWER
                                EditorGUILayout.EnumFlagsField(aiComponentDefaultValue);
#else
                                EditorGUILayout.EnumMaskField(aiComponentDefaultValue);
#endif
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.intValue = (int)aiComponentDefaultValue;
                                }
                                PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiPrimitiveType:
                            var aiPrimitiveTypeDefaultValue = hasDefaultValue ? (AiPrimitiveType)defaultValue : AiPrimitiveType.Line;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
#if UNITY_2017_3_OR_NEWER
                                EditorGUILayout.EnumFlagsField(aiPrimitiveTypeDefaultValue);
#else
                                EditorGUILayout.EnumMaskField(aiPrimitiveTypeDefaultValue);
#endif
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.intValue = (int)aiPrimitiveTypeDefaultValue;
                                }
                                PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiUVTransform:
                            var aiUvTransformDefaultValue = hasDefaultValue ? (AiUVTransform)defaultValue : AiUVTransform.Rotation;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
#if UNITY_2017_3_OR_NEWER
                                EditorGUILayout.EnumFlagsField(aiUvTransformDefaultValue);
#else
                                EditorGUILayout.EnumMaskField(aiUvTransformDefaultValue);
#endif
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.intValue = (int)aiUvTransformDefaultValue;
                                }
                                PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiMatrix:
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                GUILayout.BeginVertical();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Translation", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.Vector3Field(GUIContent.none, Vector3.zero);
                                GUILayout.EndHorizontal();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Rotation", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.Vector3Field(GUIContent.none, Vector3.zero);
                                GUILayout.EndHorizontal();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Scale", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.Vector3Field(GUIContent.none, Vector3.one);
                                GUILayout.EndHorizontal();
                                GUILayout.EndVertical();
                            }
                            else
                            {
                                GUI.enabled = true;
                                var valueSerializedProperty1 = elementSerializedProperty.FindPropertyRelative("TranslationValue");
                                var valueSerializedProperty2 = elementSerializedProperty.FindPropertyRelative("RotationValue");
                                var valueSerializedProperty3 = elementSerializedProperty.FindPropertyRelative("ScaleValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty1.vector3Value = Vector3.zero;
                                    valueSerializedProperty2.vector3Value = Vector3.zero;
                                    valueSerializedProperty3.vector3Value = Vector3.one;
                                }
                                GUILayout.BeginVertical();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Translation", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.PropertyField(valueSerializedProperty1, GUIContent.none, true, GUILayout.MinWidth(100));
                                GUILayout.EndHorizontal();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Rotation", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.PropertyField(valueSerializedProperty2, GUIContent.none, true, GUILayout.MinWidth(100));
                                GUILayout.EndHorizontal();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Scale", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.PropertyField(valueSerializedProperty3, GUIContent.none, true, GUILayout.MinWidth(100));
                                GUILayout.EndHorizontal();
                                GUILayout.EndVertical();
                            }
                            break;
                        }
                        GUI.enabled = true;
                        EditorGUILayout.EndToggleGroup();
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            break;
            }
            if (EditorGUI.EndChangeCheck())
            {
                _hasChanged = true;
            }
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUI.enabled = _hasChanged;
            if (GUILayout.Button("Revert"))
            {
                DestroyTempObject();
                _tempAssetLoaderOptions = AssetLoaderOptions.CreateInstance();
                SaveChanges();
            }
            if (GUILayout.Button("Apply"))
            {
                _tempSerializedObject.ApplyModifiedProperties();
                SaveChanges();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }