Ejemplo n.º 1
0
        public static void FolderCreate(bool small)
        {
            Helpful.Debug("Kinogoblin Editor ", " Create folder catalog");
            string path = "Assets/__Project__";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            Directory.CreateDirectory(path + "/Materials");
            Directory.CreateDirectory(path + "/Prefabs");
            Directory.CreateDirectory(path + "/Scripts");
            Directory.CreateDirectory(path + "/Scenes");
            Directory.CreateDirectory(path + "/Trash");
            if (!small)
            {
                Directory.CreateDirectory(path + "/Animations");
                Directory.CreateDirectory(path + "/Animations/AnimationClips");
                Directory.CreateDirectory(path + "/Animations/Timelines");
                Directory.CreateDirectory(path + "/Editor");
                Directory.CreateDirectory(path + "/Audio");
                Directory.CreateDirectory(path + "/Models");
                Directory.CreateDirectory(path + "/Materials/Textures");
                Directory.CreateDirectory(path + "/Materials/Shaders");
            }
            AssetDatabase.Refresh();
        }
Ejemplo n.º 2
0
        static void AddFolderToGitignore()
        {
            var ignoreFile = Path.Combine(Application.dataPath, @"..\", ".gitignore");

            Debug.Log($"Constructed path: {ignoreFile}");

            if (!File.Exists(ignoreFile))
            {
                Debug.LogError($"[Editor Extenstions] .gitignore file not found. Operation aborted");
                return;
            }

            var selection = Selection.activeObject;

            if (selection == null)
            {
                return;
            }

            var selectionPath = AssetDatabase.GetAssetPath(selection.GetInstanceID());

            if (selectionPath.Length < 0 || !Directory.Exists(selectionPath))
            {
                Debug.LogError("[Editor Extensions] Selected object is not a folder. Operation aborted");
                return;
            }

            using (var writer = new StreamWriter(ignoreFile, true))
            {
                writer.WriteLine($"{selectionPath}/");
                writer.WriteLine($"{selectionPath}*.*meta");

                Helpful.Debug("Kinogoblin Editor ", $"Folder {selection.name} successfully added to .gitignore");
            }
        }
Ejemplo n.º 3
0
            static void CheckNewMaterial(GameObject activeObject)
            {
                var AllObjects = new List <Transform>();

                AllObjects.Add(activeObject.transform);
                Helpful.GetListOfAllChilds(activeObject.transform, AllObjects);
                ChangeNewMaterial(AllObjects, activeObject);
            }
Ejemplo n.º 4
0
 public static void SceneCreate()
 {
     Helpful.Debug("Kinogoblin Editor ", " Create scene catalog");
     var cameraObj  = new GameObject("p--Player").transform;
     var scriptObj  = new GameObject("m--Managers").transform;
     var lightObj   = new GameObject("l--Light").transform;
     var staticObj  = new GameObject("e--Enviroment").transform;
     var dinamicObj = new GameObject("i--Interactable").transform;
     var audioObj   = new GameObject("s--Sound").transform;
     var timelines  = new GameObject("t--Timelines").transform;
 }
Ejemplo n.º 5
0
 public static void SetCheckMaterial(Material mat)
 {
     if (Selection.activeGameObject != null)
     {
         CheckCheckedMaterial(Selection.activeGameObject, mat);
     }
     else
     {
         Helpful.Debug("Kinogoblin Editor ", "Please select the want object in the scene");
     }
 }
Ejemplo n.º 6
0
            static void CheckCheckedMaterial(GameObject activeObject, Material mat)
            {
                var AllObjects = new List <Transform>();

                AllObjects.Add(activeObject.transform);
                Helpful.GetListOfAllChilds(activeObject.transform, AllObjects);
                if (mat != null)
                {
                    ChangeCheckedMaterial(AllObjects, activeObject, mat);
                }
                else
                {
                    ChangeCheckedMaterial(AllObjects, activeObject);
                }
            }
Ejemplo n.º 7
0
        public static void OtherGUI()
        {
            ScriptableObject   scriptableObj = settings;
            SerializedObject   serialObj     = new SerializedObject(scriptableObj);
            SerializedProperty serialProp    = serialObj.FindProperty("customHierarchy");

            ///////////////
            GUILayout.Box("COLOR SETTINGS", headerStyle, GUILayout.ExpandWidth(true), headerHeight);

            GUILayout.Space(10f);

            EditorGUILayout.PropertyField(serialProp, true);
            serialObj.ApplyModifiedProperties();

            GUILayout.Space(10f);

            settings.debugColor = EditorGUILayout.ColorField("Color debug", settings.debugColor);

            if (GUILayout.Button("Test Debug color"))
            {
                Helpful.Debug("Hello from Kinogoblin!");
            }

            GUILayout.Space(10f);

            if (GUILayout.Button("Load Kinogoblin layout"))
            {
                LayoutLoader.LoadKinogoblinLayout();
            }

            GUILayout.Space(10f);

            if (GUILayout.Button("Cleanup Missing Scripts"))
            {
                CleanupMissingScripts();
            }

            GUILayout.Space(10f);

            settings.customView = EditorGUILayout.Toggle("Custom View", settings.customView);
            settings.debugSend  = EditorGUILayout.Toggle("Debug send", settings.debugSend);
        }
Ejemplo n.º 8
0
        private static void SaveMesh(MeshFilter meshFilter, string name, bool saveAsAsset)
        {
            if (IsPrefab(meshFilter))
            {
                Debug.LogWarning("Modifying prefabs directly is not allowed, create an instance in the scene instead!");
                return;
            }

            string savedMeshName = meshFilter.sharedMesh.name;

            while (savedMeshName.EndsWith("(Clone)"))
            {
                savedMeshName = savedMeshName.Substring(0, savedMeshName.Length - 7);
            }

            string savePath = pathCustom + name + "_" + savedMeshName + "." + (saveAsAsset ? "asset" : "obj");

            if (string.IsNullOrEmpty(savePath))
            {
                return;
            }
            Helpful.Debug(savePath);

            Mesh originalMesh = meshFilter.sharedMesh;
            Mesh savedMesh    = saveAsAsset ? SaveMeshAsAsset(meshFilter, savePath) : SaveMeshAsOBJ(meshFilter, savePath);

            if (meshFilter.sharedMesh != savedMesh)
            {
                Undo.RecordObject(meshFilter, UNDO_SAVE_MODEL_AS);
                meshFilter.sharedMesh = savedMesh;
            }

            MeshCollider[] meshColliders = meshFilter.GetComponents <MeshCollider>();
            foreach (MeshCollider meshCollider in meshColliders)
            {
                if (!IsNull(meshCollider) && meshCollider.sharedMesh == originalMesh && meshCollider.sharedMesh != savedMesh)
                {
                    Undo.RecordObject(meshCollider, UNDO_SAVE_MODEL_AS);
                    meshCollider.sharedMesh = savedMesh;
                }
            }
        }
Ejemplo n.º 9
0
        /// //////////////////////
        ///

        public static void SettingsForGameobjectGUI()
        {
            GUILayout.Box("SETTINGS FOR GO", headerStyle, GUILayout.ExpandWidth(true), headerHeight);

            GUILayout.Space(10f);

            if (GUILayout.Button("Create child Pivote in center"))
            {
                SetGameObjestSettings.SetPivote();
            }
            if (GUILayout.Button("Create group of GO"))
            {
                SetGameObjestSettings.CreateGroup();
            }

            if (buttonStyle == null)
            {
                buttonStyle = new GUIStyle(GUI.skin.button)
                {
                    richText = true
                };
                headerStyle = new GUIStyle(GUI.skin.box)
                {
                    alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Bold
                };
            }


            GUILayout.Box("ADJUST PIVOT", headerStyle, GUILayout.ExpandWidth(true), headerHeight);

            Transform selection = Selection.activeTransform;

            if (!IsNull(selection))
            {
                if (!IsNull(selection.parent))
                {
                    if (selection.localPosition != Vector3.zero || selection.localEulerAngles != Vector3.zero)
                    {
                        if (GUILayout.Button("Move and rotate <b>" + selection.parent.name + "</b>'s pivot here", buttonStyle, buttonHeight))
                        {
                            SetParentPivot(selection, false);
                        }

                        if (selection.localEulerAngles != Vector3.zero)
                        {
                            EditorGUILayout.HelpBox("Pivot will also be rotated to match " + selection.name + "'s rotation.", MessageType.None);
                        }

                        if (GUILayout.Button("Move <b>" + selection.parent.name + "</b>'s pivot here", buttonStyle, buttonHeight))
                        {
                            SetParentPivot(selection, true);
                        }
                    }
                    else
                    {
                        GUI.enabled = false;
                        GUILayout.Button("Selected object is at pivot position", buttonStyle, buttonHeight);
                        GUI.enabled = true;
                    }
                }
                else
                {
                    GUI.enabled = false;
                    GUILayout.Button("Selected object has no parent", buttonStyle, buttonHeight);
                    GUI.enabled = true;
                }
            }
            else
            {
                GUI.enabled = false;
                GUILayout.Button("Nothing is selected", buttonStyle, buttonHeight);
                GUI.enabled = true;
            }

            GUILayout.Space(15f);

            auroSaveChangedMesh = EditorGUILayout.ToggleLeft("AutoSave Mesh", auroSaveChangedMesh);

            GUILayout.Space(15f);

            GUILayout.Box("MESH UTILITY", headerStyle, GUILayout.ExpandWidth(true), headerHeight);

            GUILayout.Space(5f);

            GUILayout.Label("Custom path " + pathCustom);

            if (GUILayout.Button("Set default path", buttonStyle, buttonHeight))
            {
                pathCustom = "Assets/__Project__/Models/MeshAssets/";
                Helpful.Debug(pathCustom);
            }
            if (GUILayout.Button("Save custom path", buttonStyle, buttonHeight))
            {
                var temp = pathCustom;
                pathCustom = EditorUtility.SaveFolderPanel("Save custom path", "", string.Empty);
                int      i          = 0;
                bool     normalPath = false;
                string[] tempPath   = Helpful.GetName(pathCustom, '/');
                foreach (var item in tempPath)
                {
                    if (item.Contains("Assets"))
                    {
                        normalPath = true;
                        pathCustom = "";
                        for (int j = i; j < tempPath.Length; j++)
                        {
                            pathCustom += tempPath[j] + "/";
                        }
                        continue;
                    }
                    else
                    {
                        i++;
                    }
                }
                if (!normalPath)
                {
                    Helpful.Debug("Find path in project!!!");
                    pathCustom = temp;
                }
                else
                {
                    Helpful.Debug(pathCustom);
                }
            }

            EditorGUILayout.HelpBox("If an object has a MeshFilter, changing its pivot will modify the mesh. That modified mesh must be saved before it can be applied to prefab.", MessageType.None);

            if (!IsNull(selection))
            {
                MeshFilter meshFilter = selection.GetComponent <MeshFilter>();
                if (!IsNull(meshFilter) && !IsNull(meshFilter.sharedMesh))
                {
                    if (GUILayout.Button("Save <b>" + selection.name + "</b>'s mesh as Asset (Recommended)", buttonStyle, buttonHeight))
                    {
                        if (!Directory.Exists(pathCustom))
                        {
                            Directory.CreateDirectory(pathCustom);
                        }
                        SaveMesh(meshFilter, selection.name, true);
                    }

                    GUILayout.Space(5f);

                    if (GUILayout.Button("Save <b>" + selection.name + "</b>'s mesh as OBJ", buttonStyle, buttonHeight))
                    {
                        if (!Directory.Exists(pathCustom))
                        {
                            Directory.CreateDirectory(pathCustom);
                        }
                        SaveMesh(meshFilter, selection.name, false);
                    }
                }
                else
                {
                    GUI.enabled = false;
                    GUILayout.Button("Selected object has no mesh", buttonStyle, buttonHeight);
                    GUI.enabled = true;
                }

                GUILayout.Space(5f);

                if (GUILayout.Button("Save all meshes as Asset (Recommended)", buttonStyle, buttonHeight))
                {
                    if (!Directory.Exists(pathCustom))
                    {
                        Directory.CreateDirectory(pathCustom);
                    }
                    for (int i = 0; i < Selection.gameObjects.Length; i++)
                    {
                        MeshFilter meshFilterGO = Selection.gameObjects[i].GetComponent <MeshFilter>();
                        if (!IsNull(meshFilterGO) && !IsNull(meshFilterGO.sharedMesh))
                        {
                            SaveMesh(meshFilterGO, Selection.gameObjects[i].name + "" + i, true);
                        }
                    }
                }

                GUILayout.Space(5f);

                if (GUILayout.Button("Save all meshes as OBJ", buttonStyle, buttonHeight))
                {
                    if (!Directory.Exists(pathCustom))
                    {
                        Directory.CreateDirectory(pathCustom);
                    }
                    for (int i = 0; i < Selection.gameObjects.Length; i++)
                    {
                        MeshFilter meshFilterGO = Selection.gameObjects[i].GetComponent <MeshFilter>();
                        if (!IsNull(meshFilterGO) && !IsNull(meshFilterGO.sharedMesh))
                        {
                            SaveMesh(meshFilterGO, Selection.gameObjects[i].name + "" + i, false);
                        }
                    }
                }
            }
            else
            {
                GUI.enabled = false;
                GUILayout.Button("Nothing is selected", buttonStyle, buttonHeight);
                GUI.enabled = true;
            }

            GUILayout.Space(15f);

            GUILayout.Box("SETTINGS", headerStyle, GUILayout.ExpandWidth(true), headerHeight);

            EditorGUI.BeginChangeCheck();
            createColliderObjectOnPivotChange = EditorGUILayout.ToggleLeft("Create Child Collider Object On Pivot Change", createColliderObjectOnPivotChange);
            EditorGUILayout.HelpBox("Note that original collider(s) (if exists) will not be destroyed automatically.", MessageType.None);
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetBool("AdjustPivotCreateColliders", createColliderObjectOnPivotChange);
            }

            GUILayout.Space(10f);

            EditorGUI.BeginChangeCheck();
            createNavMeshObstacleObjectOnPivotChange = EditorGUILayout.ToggleLeft("Create Child NavMesh Obstacle Object On Pivot Change", createNavMeshObstacleObjectOnPivotChange);
            EditorGUILayout.HelpBox("Note that original NavMesh Obstacle (if exists) will not be destroyed automatically.", MessageType.None);
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetBool("AdjustPivotCreateNavMeshObstacle", createNavMeshObstacleObjectOnPivotChange);
            }

            GUILayout.Space(10f);

            if (GUILayout.Button("Tern off rendering shadows for gameObjects"))
            {
                Debug.Log("<color=blue>Kinogoblin Editor</color> Off shadows");
                SetGameObjestSettings.Shadows(false);
            }
            if (GUILayout.Button("Tern on rendering shadows for gameObjects"))
            {
                Debug.Log("<color=blue>Kinogoblin Editor</color> On shadows");
                SetGameObjestSettings.Shadows(true);
            }
        }
Ejemplo n.º 10
0
        public static void ChangeMaterialGUI()
        {
            if (buttonStyle == null)
            {
                buttonStyle = new GUIStyle(GUI.skin.button)
                {
                    richText = true
                };
                headerStyle = new GUIStyle(GUI.skin.box)
                {
                    alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Bold
                };
            }

            GUILayout.Box("SETTINGS FOR GO", headerStyle, GUILayout.ExpandWidth(true), headerHeight);

            GUILayout.Label("Base settings for new material", EditorStyles.boldLabel);
            GUILayout.Space(10f);

            EditorGUILayout.BeginHorizontal();
            source = EditorGUILayout.ObjectField("Set material", source, typeof(UnityEngine.Object), true);
            EditorGUILayout.EndHorizontal();
            if (GUILayout.Button("Set checked material"))
            {
                Helpful.Debug("Kinogoblin Editor ", "Set checked material");
                if (source != null)
                {
                    try
                    {
                        checkedMaterial = (Material)source;
                    }
                    catch
                    {
                        checkedMaterial = null;
                        Debug.LogError("<color=blue>Kinogoblin Editor</color> This file is not material! I'll look for material by object name");
                    }
                }
                SetMaterialButton.SetCheckMaterial(checkedMaterial);
            }

            GUILayout.Space(10f);

            if (GUILayout.Button("Set new material"))
            {
                Helpful.Debug("Kinogoblin Editor ", "Set new material");
                SetMaterialButton.SetMaterialNew();
            }

            GUILayout.Box("MATERIAL SAVER FROM OBJECTS", headerStyle, GUILayout.ExpandWidth(true), headerHeight);

            GUILayout.Space(5f);

            GUILayout.Label("Custom path " + pathCustom);

            if (GUILayout.Button("Set default path", buttonStyle, buttonHeight))
            {
                pathCustom = "Assets/__Project__/Materials/";
                Helpful.Debug(pathCustom);
            }
            if (GUILayout.Button("Save custom path", buttonStyle, buttonHeight))
            {
                var temp = pathCustom;
                pathCustom = EditorUtility.SaveFolderPanel("Save custom path", "", string.Empty);
                int      i          = 0;
                bool     normalPath = false;
                string[] tempPath   = Helpful.GetName(pathCustom, '/');
                foreach (var item in tempPath)
                {
                    if (item.Contains("Assets"))
                    {
                        normalPath = true;
                        pathCustom = "";
                        for (int j = i; j < tempPath.Length; j++)
                        {
                            pathCustom += tempPath[j] + "/";
                        }
                        continue;
                    }
                    else
                    {
                        i++;
                    }
                }
                if (!normalPath)
                {
                    Helpful.Debug("Find path in project!!!");
                    pathCustom = temp;
                }
                else
                {
                    Helpful.Debug(pathCustom);
                }
            }

            Transform selection = Selection.activeTransform;

            if (!IsNull(selection))
            {
                if (GUILayout.Button("Copy and save <b>" + selection.name + "</b>'s materials!", buttonStyle, buttonHeight))
                {
                    var pathWithName = pathCustom + "/" + selection.name + "/";
                    if (!Directory.Exists(pathWithName))
                    {
                        Directory.CreateDirectory(pathWithName);
                    }
                    SaveMaterialButton.SaveMaterialFromGameObject(pathWithName, selection);
                }

                GUILayout.Space(5f);
            }
            else
            {
                GUI.enabled = false;
                GUILayout.Button("Selected object for save materials", buttonStyle, buttonHeight);
                GUI.enabled = true;
            }
        }