Пример #1
0
        private void OnGUI()
        {
            EditorGUILayout.LabelField("ForestVision Tree Creator and Asset Collection Browser", EditorStyles.boldLabel);
            EditorGUILayout.Space();

            DrawTabs();
            EditorGUILayout.HelpBox("Select an asset to add it to the scene. Newly created objects will by default be the child of anything selected. New objects will be placed at (0,0,0) of its parent object.", MessageType.None);
            DrawScroll();

            EditorGUILayout.Space();

            EditorGUILayout.Space();

            GUILayout.BeginHorizontal("box");


            #region Tree Tools
            if (GUILayout.Button("Tree Tools", GUILayout.Width(160), GUILayout.MinHeight(60)))
            {
                FV_TreeTools.ShowWindow();
            }
            GUILayout.Space(guiSpace);
            #endregion

            #region Reset Transform
            if (GUILayout.Button("Reset Transform", GUILayout.Width(160), GUILayout.MinHeight(60)))
            {
                var go = Selection.activeGameObject;
                if (go == null)
                {
                    if (EditorUtility.DisplayDialog("Heads Up", "Can't reset the transforms without something selected", "OK"))
                    {
                        return;
                    }
                }
                ResetTransformOnSelected(go);
            }
            GUILayout.Space(guiSpace);

            #endregion

            #region Add FV Items Script
            if (GUILayout.Button("Add FV_Items Script", GUILayout.Width(160), GUILayout.MinHeight(60)))
            {
                var go = Selection.activeGameObject;
                if (go == null)
                {
                    if (EditorUtility.DisplayDialog("Heads Up", "Gotta select something before we put a script on it", "OK"))
                    {
                        return;
                    }
                }

                go.AddComponent <FV_Items>();
            }
            GUILayout.Space(guiSpace);
            #endregion

            #region Collapse Mesh


            if (GUILayout.Button("New Optimized", GUILayout.Width(160), GUILayout.MinHeight(60)))
            {
                var go = Selection.activeGameObject;
                if (go == null)
                {
                    if (EditorUtility.DisplayDialog("Heads Up", "Can't collapse without something selected", "OK"))
                    {
                        return;
                    }
                }

                FV_Collapse.CombineMeshes(go);

                foreach (GameObject tree in FV_Collapse.childrenOfTree)
                {
                    DestroyImmediate(tree.gameObject);
                }

                go.GetComponent <FV_Items>().category = FV_Items.Category.Optimized;
                go.GetComponent <FV_Items>().itemName = go.name;
                //string nameStamp = string.Format ("{0}_FV_{1}x", "My", System.DateTime.Now.ToString ("MM-dd-yyyy_mm-ss"));
                PrefabUtility.SaveAsPrefabAsset(Selection.activeGameObject, optimizedPath + go.name + ".prefab");

                InitContent();
                GeneratePreviews();
            }
            GUILayout.Space(guiSpace);
            #endregion

            #region Save Prefab
            if (GUILayout.Button("New Prefab", GUILayout.Width(160), GUILayout.MinHeight(60)))
            {
                var go = Selection.activeGameObject;
                if (go == null)
                {
                    if (EditorUtility.DisplayDialog("Heads Up", "Gotta select something to prefab", "OK"))
                    {
                        return;
                    }
                }

                go.GetComponent <FV_Items>().category = FV_Items.Category.Trees;
                //string nameStamp = string.Format ("{0}_FV_{1}x", "My", System.DateTime.Now.ToString ("MM-dd-yyyy_mm-ss"));
                //var prefab = PrefabUtility.CreatePrefab (prefabPath + go.name + ".prefab", Selection.activeGameObject);
                PrefabUtility.SaveAsPrefabAsset(Selection.activeGameObject, prefabPath + go.name + ".prefab");
                InitContent();
                GeneratePreviews();
            }
            GUILayout.Space(guiSpace);
            #endregion

            #region Screenshotter
            if (GUILayout.Button("Screen Shot", GUILayout.Width(160), GUILayout.MinHeight(60)))
            {
                FV_Screenshots.ShowWindow();
            }
            GUILayout.Space(guiSpace);

            #endregion

            #region Refresh Database
            if (GUILayout.Button("Refresh Database", GUILayout.Width(160), GUILayout.MinHeight(60)))
            {
                InitContent();
                GeneratePreviews();
            }
            #endregion

            /*
             *          if (GUILayout.Button ("Show Help", GUILayout.Width (160), GUILayout.MinHeight (60))) {
             *                  if (EditorUtility.DisplayDialog ("Editor Help", "All assets are located within: Assets/ForestVision/" +
             *                                                   "\n" +
             *                                                   "\nTo add your own models to this collection, simply:" +
             *                                                   "\n" +
             *                                                   "\n1) Place them anywhere inside the: Assets/ForestVision/ folder" +
             *                                                   "\n2) Assign the FV_Item script to your model" +
             *                                                   "\n3) Set the Category in the FV_Script, ie = Prefabs, Optimized, Flora, etc., as appropriate." +
             *                                                   "\n4) Set the Item Name in the FV_Scripts to something meaningful to you." +
             *                                                   "\n" +
             *                                                   "\n[ Refresh Database ] will re-generate thumbnails if you add new assets and they don't appear in the browser right away." +
             *                                                   "\n" +
             *                                                   "[ New Optimized ] will collapse your selected tree creations down into a single mesh, while preserving materials.   It will save the tree into the:  ForestVision/08 Optimized/07 MyOptimized folder, and assign it's Editor Category so it will show up here under the Optimized tab." +
             *                                                   "\n" +
             *                                                   "[ New Prefab ] will simply save your selected tree arrangement as a new prefab inside: ForestVision/ 06 Specials/ MyPrefabs. Nothing will be collapsed. Everything will be preserved.", "OK"))
             *                          return;
             *          }
             */

            GUILayout.EndHorizontal();
        }
Пример #2
0
    private void OnGUI()
    {
        GUILayout.BeginHorizontal("box");



        if (GUILayout.Button("Tree Tools", GUILayout.Width(160), GUILayout.MinHeight(60)))
        {
            FV_TreeTools.ShowWindow();
        }
        GUILayout.Space(guiSpace);
        if (GUILayout.Button("Reset Transform", GUILayout.Width(160), GUILayout.MinHeight(60)))
        {
            var go = Selection.activeGameObject;
            if (go == null)
            {
                if (EditorUtility.DisplayDialog("Heads Up", "Can't reset the transforms without something selected", "OK"))
                {
                    return;
                }
            }
            FV_EditorWindow.ResetTransformOnSelected(go);
        }
        GUILayout.Space(guiSpace);
        // ----------------- Collapse Mesh ----------------------

        if (GUILayout.Button("New Optimized", GUILayout.Width(160), GUILayout.MinHeight(60)))
        {
            var go = Selection.activeGameObject;
            if (go == null)
            {
                if (EditorUtility.DisplayDialog("Heads Up", "Can't collapse without something selected", "OK"))
                {
                    return;
                }
            }

            FV_Collapse.CombineMeshes(go);

            foreach (GameObject tree in FV_Collapse.childrenOfTree)
            {
                DestroyImmediate(tree.gameObject);
            }

            go.GetComponent <FV_Items>().category = FV_Items.Category.Optimized;
            go.GetComponent <FV_Items>().itemName = go.name;
            //string nameStamp = string.Format ("{0}_FV_{1}x", "My", System.DateTime.Now.ToString ("MM-dd-yyyy_mm-ss"));
            PrefabUtility.SaveAsPrefabAsset(Selection.activeGameObject, optimizedPath + go.name + ".prefab");

            //			InitContent ();
            //			GeneratePreviews ();
        }

        GUILayout.Space(guiSpace);
        //-------------------- Save Prefab -----------------------


        if (GUILayout.Button("New Prefab", GUILayout.Width(160), GUILayout.MinHeight(60)))
        {
            var go = Selection.activeGameObject;
            if (go == null)
            {
                if (EditorUtility.DisplayDialog("Heads Up", "Gotta select something to prefab", "OK"))
                {
                    return;
                }
            }

            go.GetComponent <FV_Items>().category = FV_Items.Category.Trees;
            //string nameStamp = string.Format ("{0}_FV_{1}x", "My", System.DateTime.Now.ToString ("MM-dd-yyyy_mm-ss"));
            //var prefab = PrefabUtility.CreatePrefab (prefabPath + go.name + ".prefab", Selection.activeGameObject);
            PrefabUtility.SaveAsPrefabAsset(Selection.activeGameObject, prefabPath + go.name + ".prefab");
            //			InitContent ();
            //			GeneratePreviews ();
        }

        GUILayout.Space(guiSpace);

        if (GUILayout.Button("Add\nFV_BranchRotation\nScript", GUILayout.Width(160), GUILayout.MinHeight(60)))
        {
            var go = Selection.activeGameObject;
            if (go == null)
            {
                if (EditorUtility.DisplayDialog("Heads Up", "Gotta select something before we put a script on it", "OK"))
                {
                    return;
                }
            }

            go.AddComponent <FV_BranchRotation>();
        }
        GUILayout.Space(guiSpace);

        if (GUILayout.Button("Add\nFV_Items\nScript", GUILayout.Width(160), GUILayout.MinHeight(60)))
        {
            var go = Selection.activeGameObject;
            if (go == null)
            {
                if (EditorUtility.DisplayDialog("Heads Up", "Gotta select something before we put a script on it", "OK"))
                {
                    return;
                }
            }

            go.AddComponent <FV_Items>();
        }
        GUILayout.Space(guiSpace);

        if (GUILayout.Button("Screen Shot", GUILayout.Width(160), GUILayout.MinHeight(60)))
        {
            FV_Screenshots.ShowWindow();
        }
    }