// ---------------------------------------------------------------------------
    // Create a New Grid in the Hierarchy from the Grid Prefab
    // ---------------------------------------------------------------------------
    static void CreateNewGrid()
    {
        // Create new Grid GameObject
        gridGameObject = GameObject.CreatePrimitive(PrimitiveType.Plane);
        gridGameObject.transform.position = new Vector3(0f, 0f, 0f);
        gridGameObject.name  = MAST_Const.grid.defaultName;
        gridGameObject.layer = 4;

        // Configure Grid GameObject MeshRenderer
        MeshRenderer gridMeshRenderer = gridGameObject.GetComponent <MeshRenderer>();

        gridMeshRenderer.lightProbeUsage      = UnityEngine.Rendering.LightProbeUsage.Off;
        gridMeshRenderer.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off;
        gridMeshRenderer.shadowCastingMode    = UnityEngine.Rendering.ShadowCastingMode.Off;
        gridMeshRenderer.receiveShadows       = false;

        // Configure Grid GameObject Material
        if (gridMaterial == null)
        {
            gridMaterial = MAST_Asset_Loader.GetGridMaterial();
        }
        gridMaterial.SetColor("_Color", MAST_Settings.gui.grid.tintColor);
        gridMeshRenderer.material = gridMaterial;

        // Add MAST_Grid_Component script to grid and pass grid preferences to it
        UpdateGridSettings();

        // Return the grid to its last saved height
        MoveGridToNewHeight();

        // Hide the grid in the hierarchy
        gridGameObject.hideFlags = HideFlags.HideInHierarchy;
    }
コード例 #2
0
    // ---------------------------------------------------------------------------
    // Load preferences from state scriptable object
    // ---------------------------------------------------------------------------
    public static void Restore_Palette_Items()
    {
        // Get or scriptable object to store the interface state data
        Get_Reference_To_Scriptable_Object();

        // Get palette item count
        int paletteItemCount = state.prefabs.Length;

        // Load palette item tooltips
        string[] paletteItemTooltip = state.paletteItemTooltip;

        // Create empty Texture2D array and empty GUIContent array
        Texture2D[]  paletteTexture2D  = new Texture2D[paletteItemCount];
        GUIContent[] paletteGuiContent = new GUIContent[paletteItemCount];

        // Get texture path to save palette images
        string texturePath = MAST_Asset_Loader.GetMASTRootFolder() + "/Etc/Temp/temp_palette_image_";

        // Loop through each palette item
        for (int i = 0; i < paletteItemCount; i++)
        {
            // Load Texture2D saved as PNG on disk back to palette item
            byte[] bytes = File.ReadAllBytes(texturePath + i.ToString("000") + ".png");
            paletteTexture2D[i] = new Texture2D(2, 2);
            paletteTexture2D[i].LoadImage(bytes);
        }

        // Copy palette GUI content to Palette class
        MAST_Palette.RestorePaletteData(state.prefabs, paletteTexture2D, paletteItemTooltip);
    }
コード例 #3
0
ファイル: MAST_PrepModels.cs プロジェクト: Trevor802/VII
    // ---------------------------------------------------------------------------

    // ---------------------------------------------------------------------------
    // Add MAST Scripts to Prefabs in Folder
    // ---------------------------------------------------------------------------
    public void AddMASTScriptsToPrefabsInFolder()
    {
        // Show choose folder dialog
        string chosenPath = EditorUtility.OpenFolderPanel("Choose the Folder that Contains your Prefabs",
                                                          MAST_Interface_Data_Manager.state.lastPrefabPath, "");

        // If a folder was chosen "Cancel was not clicked"
        if (chosenPath != "")
        {
            // Save the path the user chose
            MAST_Interface_Data_Manager.state.lastPrefabPath = chosenPath;
            MAST_Interface_Data_Manager.Save_Changes_To_Disk();

            // Convert to project local path "Assets/..."
            string assetPath = chosenPath.Replace(Application.dataPath, "Assets");

            // Loop through each Prefab in folder
            foreach (GameObject prefab in MAST_Asset_Loader.GetPrefabsInFolder(assetPath))
            {
                // Add MAST Prefab script if not already added
                if (!prefab.GetComponent <MAST_Prefab_Component>())
                {
                    prefab.AddComponent <MAST_Prefab_Component>();
                }
            }
        }
    }
コード例 #4
0
    // Change visualizer to eraser
    public static void ChangePrefabToEraser()
    {
        // Remove any existing visualizer
        MAST_Placement_Visualizer.RemoveVisualizer();

        // Create a new visualizer with eraser
        MAST_Placement_Visualizer.CreateVisualizer(MAST_Asset_Loader.GetEraserPrefab());
    }
コード例 #5
0
    // ---------------------------------------------------------------------------
    // Get or create the state scriptable object
    // ---------------------------------------------------------------------------
    private static void Get_Reference_To_Scriptable_Object()
    {
        // Get MAST Core path
        string statePath = MAST_Asset_Loader.GetMASTRootFolder() + "/Etc/MAST_Interface_State.asset";

        // Load the MAST Core scriptable object
        state = AssetDatabase.LoadAssetAtPath <MAST_Interface_ScriptableObject>(statePath);

        // If the Core scriptable object isn't found, create a new default one
        if (state == null)
        {
            state = ScriptableObject.CreateInstance <MAST_Interface_ScriptableObject>();
            AssetDatabase.CreateAsset(state, statePath);
        }
    }
コード例 #6
0
    public static void Load_Core_Settings()
    {
        // Get MAST Core path
        string corePath = MAST_Asset_Loader.GetMASTRootFolder() + "/Etc/MAST_Core_Settings.asset";

        // Load the MAST Core scriptable object
        core = AssetDatabase.LoadAssetAtPath <MAST_Core_ScriptableObject>(corePath);

        // If the Core scriptable object isn't found, create a new default one
        if (core == null)
        {
            core = ScriptableObject.CreateInstance <MAST_Core_ScriptableObject>();
            AssetDatabase.CreateAsset(core, corePath);
        }
    }
コード例 #7
0
    // ---------------------------------------------------------------------------
    // Save preferences to state scriptable object
    // ---------------------------------------------------------------------------
    public static void Save_Palette_Items(bool forceSave = false)
    {
        // Get or create a scriptable object to store the interface state data
        Get_Reference_To_Scriptable_Object();

        // If palette data has changed or if forcing a save "from loading new prefabs with button"
        if (MAST_Palette.GetPrefabArray() != state.prefabs || forceSave)
        {
            // Delete any previous palette items same in the "MAST/Etc/Temp" folder
            string paletteImagePath = MAST_Asset_Loader.GetMASTRootFolder() + "/Etc/Temp";
            if (Directory.Exists(paletteImagePath))
            {
                Directory.Delete(paletteImagePath, true);
            }
            Directory.CreateDirectory(paletteImagePath);

            // Save prefabs
            state.prefabs = MAST_Palette.GetPrefabArray();

            // Define palette item tooltip array
            string[] paletteItemTooltip = new string[MAST_Palette.GetGUIContentArray().Length];

            // Get texture path to save palette images
            string texturePath = MAST_Asset_Loader.GetMASTRootFolder() + "/Etc/Temp/temp_palette_image_";

            // Loop through each item in the palette
            for (int i = 0; i < MAST_Palette.GetGUIContentArray().Length; i++)
            {
                // Get the tooltip from the palette GUIContent
                paletteItemTooltip[i] = MAST_Palette.GetGUIContentArray()[i].tooltip;

                // Encode this palette item image to PNG then save to disk
                byte[] bytes = MAST_Palette.GetTexture2DArray()[i].EncodeToPNG();
                File.WriteAllBytes(texturePath + i.ToString("000") + ".png", bytes);
            }

            // Save palette item tooltips and images (converted to byte arrays)
            state.paletteItemTooltip = paletteItemTooltip;
        }

        // Save state changes to disk
        Save_Changes_To_Disk();
    }
コード例 #8
0
// ---------------------------------------------------------------------------
    #region Load Images
// ---------------------------------------------------------------------------
    private void LoadImages()
    {
        iconGridToggle = MAST_Asset_Loader.GetImage("Grid_Toggle.png");
        iconGridUp     = MAST_Asset_Loader.GetImage("Grid_Up.png");
        iconGridDown   = MAST_Asset_Loader.GetImage("Grid_Down.png");

        guiContentDrawTool    = new GUIContent[5];
        guiContentDrawTool[0] = new GUIContent(MAST_Asset_Loader.GetImage("Pencil.png"), "Draw Single Tool");
        guiContentDrawTool[1] = new GUIContent(MAST_Asset_Loader.GetImage("Paint_Roller.png"), "Draw Continuous Tool");
        guiContentDrawTool[2] = new GUIContent(MAST_Asset_Loader.GetImage("Paint_Bucket.png"), "Paint Area Tool");
        guiContentDrawTool[3] = new GUIContent(MAST_Asset_Loader.GetImage("Randomizer.png"), "Randomizer Tool");
        guiContentDrawTool[4] = new GUIContent(MAST_Asset_Loader.GetImage("Eraser.png"), "Eraser Tool");

        iconRotate         = MAST_Asset_Loader.GetImage("Rotate.png");
        iconFlip           = MAST_Asset_Loader.GetImage("Flip.png");
        iconAxisX          = MAST_Asset_Loader.GetImage("Axis_X.png");
        iconAxisY          = MAST_Asset_Loader.GetImage("Axis_Y.png");
        iconAxisZ          = MAST_Asset_Loader.GetImage("Axis_Z.png");
        iconLoadFromFolder = MAST_Asset_Loader.GetImage("Load_From_Folder.png");
        iconSettings       = MAST_Asset_Loader.GetImage("Settings.png");
        iconTools          = MAST_Asset_Loader.GetImage("Tools.png");
    }
コード例 #9
0
    // Start paint area
    public static void StartPaintArea()
    {
        if (MAST_Placement_Visualizer.GetGameObject() != null)
        {
            // Set painting area to true
            paintingArea = true;

            // Record paint area start location
            paintAreaStart   = MAST_Placement_Visualizer.GetGameObject().transform.position;
            paintAreaStart.y = MAST_Settings.gui.grid.gridHeight *
                               MAST_Settings.gui.grid.xzUnitSize + MAST_Const.grid.yOffsetToAvoidTearing;

            // Create new Paint Area Visualizer
            paintAreaVisualizer = GameObject.CreatePrimitive(PrimitiveType.Plane);
            paintAreaVisualizer.transform.position = new Vector3(0f, 0f, 0f);
            paintAreaVisualizer.name = "MAST_Paint_Area_Visualizer";

            // Configure Paint Area Visualizer MeshRenderer
            MeshRenderer paintAreaMeshRenderer = paintAreaVisualizer.GetComponent <MeshRenderer>();
            paintAreaMeshRenderer.lightProbeUsage      = UnityEngine.Rendering.LightProbeUsage.Off;
            paintAreaMeshRenderer.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off;
            paintAreaMeshRenderer.shadowCastingMode    = UnityEngine.Rendering.ShadowCastingMode.Off;
            paintAreaMeshRenderer.receiveShadows       = false;

            // Configure Paint Area Visualizer Material
            if (paintAreaMaterial == null)
            {
                paintAreaMaterial = MAST_Asset_Loader.GetPaintAreaMaterial();
            }
            paintAreaMeshRenderer.material = paintAreaMaterial;

            // Hide the Paint Area Visualizer in the hierarchy
            paintAreaVisualizer.hideFlags = HideFlags.HideInHierarchy;

            // Update the paint area
            UpdatePaintArea();
        }
    }
コード例 #10
0
    // ---------------------------------------------------------------------------
    #region Preferences Interface
    // ---------------------------------------------------------------------------
    void OnGUI()
    {
        // Verical scroll view for palette items
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

        //if (GUILayout.Button("Old Prefab Creator"))
        //{
        //    PrepModels.CreatePrefabsFromModels();
        //}

        // ------------------------------------
        // Open PrefabCreator Window Button
        // ------------------------------------
        EditorGUILayout.LabelField("Generate Prefabs from your own models.  Substitute and consolidate materials used during the process.", EditorStyles.wordWrappedLabel);

        if (GUILayout.Button(new GUIContent("Open Prefab Creator window", "Open Prefab Creator window")))
        {
            // If PrefabCreator window is closed, show and initialize it
            if (PrefabCreator == null)
            {
                PrefabCreator = (MAST_Prefab_Creator)EditorWindow.GetWindow(
                    typeof(MAST_Prefab_Creator),
                    false, "MAST Prefab Creator");


                PrefabCreator.minSize = new Vector2(800, 250);
            }

            // If PrefabCreator window is open, close it
            else
            {
                EditorWindow.GetWindow(typeof(MAST_Prefab_Creator)).Close();
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Add MAST Script to Prefabs
        // ----------------------------------
        EditorGUILayout.LabelField("This will add a MAST script to each prefab.  The script is used to describe the type of object to the MAST editor.", EditorStyles.wordWrappedLabel);

        if (GUILayout.Button(new GUIContent("Add MAST Script to Prefabs",
                                            "Create Prefabs from all models in the selected folder.")))
        {
            // Show choose folder dialog
            string chosenPath = EditorUtility.OpenFolderPanel("Choose the Folder that Contains your Prefabs",
                                                              MAST_Interface_Data_Manager.state.lastPrefabPath, "");

            // If a folder was chosen "Cancel was not clicked"
            if (chosenPath != "")
            {
                // Save the path the user chose
                MAST_Interface_Data_Manager.state.lastPrefabPath = chosenPath;
                MAST_Interface_Data_Manager.Save_Changes_To_Disk();

                // Convert to project local path "Assets/..."
                string assetPath = chosenPath.Replace(Application.dataPath, "Assets");

                // Loop through each Prefab in folder
                foreach (GameObject prefab in MAST_Asset_Loader.GetPrefabsInFolder(assetPath))
                {
                    // Add MAST Prefab script if not already added
                    if (!prefab.GetComponent <MAST_Prefab_Component>())
                    {
                        prefab.AddComponent <MAST_Prefab_Component>();
                    }
                }
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Remove MAST Components Button
        // ----------------------------------
        EditorGUILayout.LabelField("Remove all MAST Components that were attached to the children of the selected GameObject during placement.", EditorStyles.wordWrappedLabel);

        if (GUILayout.Button(new GUIContent("Remove MAST Components",
                                            "Remove any MAST Component code attached to gameobjects during placement")))
        {
            if (EditorUtility.DisplayDialog("Are you sure?",
                                            "This will remove all MAST components attached to '" + Selection.activeGameObject.name + "'",
                                            "Remove MAST Components", "Cancel"))
            {
                // Loop through all top-level children of targetParent
                foreach (MAST_Prefab_Component prefabComponent
                         in Selection.activeGameObject.transform.GetComponentsInChildren <MAST_Prefab_Component>())
                {
                    // Remove the SMACK_Prefab_Component script
                    GameObject.DestroyImmediate(prefabComponent);
                }
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Merge Meshes by Material Button
        // ----------------------------------
        EditorGUILayout.LabelField("Merge all meshes in the selected GameObject, and place them in a new GameObject.", EditorStyles.wordWrappedLabel);

        if (GUILayout.Button(new GUIContent("Merge Meshes",
                                            "Merge all meshes by material name, resulting in one mesh for each material")))
        {
            if (EditorUtility.DisplayDialog("Are you sure?",
                                            "This will combine all meshes in '" + Selection.activeGameObject.name +
                                            "' and save them to a new GameObject.  The original GameObject will not be affected.",
                                            "Merge Meshes", "Cancel"))
            {
                GameObject targetParent = MergeMeshes.MergeMeshes(Selection.activeGameObject);
                targetParent.name = Selection.activeGameObject.name + "_Merged";
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        EditorGUILayout.EndScrollView();
    }
コード例 #11
0
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
    #region Placement Tab GUI
// ---------------------------------------------------------------------------
    private void PlacementGUI()
    {
        // Verical scroll view for palette items
        placementScrollPos = EditorGUILayout.BeginScrollView(placementScrollPos);

        // ----------------------------------
        // Placement Destination
        // ----------------------------------
        targetParent = (GameObject)EditorGUILayout.ObjectField(
            new GUIContent("Placement Destination",
                           "Drag a GameObject from the Hierarchy into this field.  It will be used as the parent of new placed models"),
            targetParent, typeof(GameObject), true);
        MAST_Settings.placement.targetParentName = targetParent.name;

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Snap to Grid
        // ----------------------------------
        GUILayout.BeginHorizontal();

        MAST_Settings.placement.snapToGrid =
            GUILayout.Toggle(MAST_Settings.placement.snapToGrid, "Snap to Grid");

        GUILayout.EndHorizontal();

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Offset
        // ----------------------------------
        placementOffsetFoldout = EditorGUILayout.Foldout(placementOffsetFoldout, "Offset Settings");
        if (placementOffsetFoldout)
        {
            EditorGUILayout.Space();

            MAST_Settings.placement.offset.pos =
                EditorGUILayout.Vector3Field("Position Offset", MAST_Settings.placement.offset.pos);

            EditorGUILayout.Space();

            MAST_Settings.placement.offset.overridePrefab =
                GUILayout.Toggle(MAST_Settings.placement.offset.overridePrefab, "Override Prefab Settings");
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Rotation
        // ----------------------------------
        placementRotationFoldout = EditorGUILayout.Foldout(placementRotationFoldout, "Rotation Settings");
        if (placementRotationFoldout)
        {
            EditorGUILayout.Space();

            MAST_Settings.placement.rotation.factor =
                EditorGUILayout.Vector3Field("Rotation Factor", MAST_Settings.placement.rotation.factor);

            EditorGUILayout.Space();

            MAST_Settings.placement.rotation.overridePrefab =
                GUILayout.Toggle(MAST_Settings.placement.rotation.overridePrefab, "Override Prefab Settings");
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Randomizer
        // ----------------------------------
        placementRandomizerFoldout = EditorGUILayout.Foldout(placementRandomizerFoldout, "Randomizer Settings");
        if (placementRandomizerFoldout)
        {
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Randomize Rotation (0 = no rotation)", EditorStyles.boldLabel);

            MAST_Settings.placement.randomizer.rotate =
                EditorGUILayout.Vector3Field("Rotation Factor", MAST_Settings.placement.randomizer.rotate);

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Randomize Scale (1 = no scaling)", EditorStyles.boldLabel);

            MAST_Settings.placement.randomizer.scaleLock =
                (MAST_Placement_ScriptableObject.AxisLock)EditorGUILayout.EnumPopup(
                    "Lock", MAST_Settings.placement.randomizer.scaleLock);

            MAST_Settings.placement.randomizer.scaleMin =
                EditorGUILayout.Vector3Field("Minimum", MAST_Settings.placement.randomizer.scaleMin);
            MAST_Settings.placement.randomizer.scaleMax =
                EditorGUILayout.Vector3Field("Maximum", MAST_Settings.placement.randomizer.scaleMax);

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Randomize Position (0 = no offset)", EditorStyles.boldLabel);

            MAST_Settings.placement.randomizer.posMin =
                EditorGUILayout.Vector3Field("Minimum", MAST_Settings.placement.randomizer.posMin);
            MAST_Settings.placement.randomizer.posMax =
                EditorGUILayout.Vector3Field("Maximum", MAST_Settings.placement.randomizer.posMax);

            EditorGUILayout.Space();

            MAST_Settings.placement.randomizer.overridePrefab =
                GUILayout.Toggle(MAST_Settings.placement.randomizer.overridePrefab, "Override Prefab Settings");
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // Get placement settings object path from selected item in project view
        if (GUILayout.Button(
                new GUIContent("Load Placement Settings from selected file in Project",
                               "Use the selected (Placement Settings) file in project")))
        {
            string path = MAST_Asset_Loader.GetPathOfSelectedObjectTypeOf(typeof(MAST_Placement_ScriptableObject));

            if (path != "")
            {
                MAST_Settings.core.placementSettingsPath = path;
                MAST_Settings.Load_Placement_Settings();
            }
        }

        EditorGUILayout.EndScrollView();
    }
コード例 #12
0
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
    #region Hotkey Tab GUI
// ---------------------------------------------------------------------------
    private void HotkeyGUI()
    {
        // Verical scroll view for palette items
        hotkeyScrollPos = EditorGUILayout.BeginScrollView(hotkeyScrollPos);

        // ----------------------------------
        // Toggle grid On/Off
        // ----------------------------------
        EditorGUILayout.LabelField("Toggle Grid On/Off", EditorStyles.boldLabel);

        MAST_Settings.hotkey.toggleGridKey =
            (KeyCode)EditorGUILayout.EnumPopup(
                "Key", MAST_Settings.hotkey.toggleGridKey);
        MAST_Settings.hotkey.toggleGridMod =
            (MAST_Hotkey_ScriptableObject.Modifier)EditorGUILayout.EnumPopup(
                "Modifier", MAST_Settings.hotkey.toggleGridMod);

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Move grid up
        // ----------------------------------
        EditorGUILayout.LabelField("Move Grid Up", EditorStyles.boldLabel);

        MAST_Settings.hotkey.moveGridUpKey =
            (KeyCode)EditorGUILayout.EnumPopup(
                "Key", MAST_Settings.hotkey.moveGridUpKey);
        MAST_Settings.hotkey.moveGridUpMod =
            (MAST_Hotkey_ScriptableObject.Modifier)EditorGUILayout.EnumPopup(
                "Modifier", MAST_Settings.hotkey.moveGridUpMod);

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Move grid down
        // ----------------------------------
        EditorGUILayout.LabelField("Move Grid Down", EditorStyles.boldLabel);

        MAST_Settings.hotkey.moveGridDownKey =
            (KeyCode)EditorGUILayout.EnumPopup(
                "Key", MAST_Settings.hotkey.moveGridDownKey);
        MAST_Settings.hotkey.moveGridDownMod =
            (MAST_Hotkey_ScriptableObject.Modifier)EditorGUILayout.EnumPopup(
                "Modifier", MAST_Settings.hotkey.moveGridDownMod);

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Deselect prefab in palette
        // ----------------------------------
        EditorGUILayout.LabelField("Deselect Draw Tool and Palette Selection", EditorStyles.boldLabel);

        MAST_Settings.hotkey.deselectPrefabKey =
            (KeyCode)EditorGUILayout.EnumPopup(
                "Key", MAST_Settings.hotkey.deselectPrefabKey);
        MAST_Settings.hotkey.deselectPrefabMod =
            (MAST_Hotkey_ScriptableObject.Modifier)EditorGUILayout.EnumPopup(
                "Modifier", MAST_Settings.hotkey.deselectPrefabMod);

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Draw single
        // ----------------------------------
        EditorGUILayout.LabelField("Select Draw Single Tool", EditorStyles.boldLabel);

        MAST_Settings.hotkey.drawSingleKey =
            (KeyCode)EditorGUILayout.EnumPopup(
                "Key", MAST_Settings.hotkey.drawSingleKey);
        MAST_Settings.hotkey.drawSingleMod =
            (MAST_Hotkey_ScriptableObject.Modifier)EditorGUILayout.EnumPopup(
                "Modifier", MAST_Settings.hotkey.drawSingleMod);

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Draw continuous
        // ----------------------------------
        EditorGUILayout.LabelField("Select Draw Continuous Tool", EditorStyles.boldLabel);

        MAST_Settings.hotkey.drawContinuousKey =
            (KeyCode)EditorGUILayout.EnumPopup(
                "Key", MAST_Settings.hotkey.drawContinuousKey);
        MAST_Settings.hotkey.drawContinuousMod =
            (MAST_Hotkey_ScriptableObject.Modifier)EditorGUILayout.EnumPopup(
                "Modifier", MAST_Settings.hotkey.drawContinuousMod);

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Paint square
        // ----------------------------------
        EditorGUILayout.LabelField("Select Paint Square Tool", EditorStyles.boldLabel);

        MAST_Settings.hotkey.paintSquareKey =
            (KeyCode)EditorGUILayout.EnumPopup(
                "Key", MAST_Settings.hotkey.paintSquareKey);
        MAST_Settings.hotkey.paintSquareMod =
            (MAST_Hotkey_ScriptableObject.Modifier)EditorGUILayout.EnumPopup(
                "Modifier", MAST_Settings.hotkey.paintSquareMod);

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Randomizer
        // ----------------------------------
        EditorGUILayout.LabelField("Select Randomizer Tool", EditorStyles.boldLabel);

        MAST_Settings.hotkey.randomizerKey =
            (KeyCode)EditorGUILayout.EnumPopup(
                "Key", MAST_Settings.hotkey.randomizerKey);
        MAST_Settings.hotkey.randomizerMod =
            (MAST_Hotkey_ScriptableObject.Modifier)EditorGUILayout.EnumPopup(
                "Modifier", MAST_Settings.hotkey.randomizerMod);

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Erase
        // ----------------------------------
        EditorGUILayout.LabelField("Select Erase Tool", EditorStyles.boldLabel);

        MAST_Settings.hotkey.eraseKey =
            (KeyCode)EditorGUILayout.EnumPopup(
                "Key", MAST_Settings.hotkey.eraseKey);
        MAST_Settings.hotkey.eraseMod =
            (MAST_Hotkey_ScriptableObject.Modifier)EditorGUILayout.EnumPopup(
                "Modifier", MAST_Settings.hotkey.eraseMod);

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // New random seed
        // ----------------------------------
        EditorGUILayout.LabelField("Generate New Random(izer) Seed", EditorStyles.boldLabel);

        MAST_Settings.hotkey.newRandomSeedKey =
            (KeyCode)EditorGUILayout.EnumPopup(
                "Key", MAST_Settings.hotkey.newRandomSeedKey);
        MAST_Settings.hotkey.newRandomSeedMod =
            (MAST_Hotkey_ScriptableObject.Modifier)EditorGUILayout.EnumPopup(
                "Modifier", MAST_Settings.hotkey.newRandomSeedMod);

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Rotate prefab
        // ----------------------------------
        EditorGUILayout.LabelField("Rotate Prefab", EditorStyles.boldLabel);

        MAST_Settings.hotkey.rotatePrefabKey =
            (KeyCode)EditorGUILayout.EnumPopup(
                "Key", MAST_Settings.hotkey.rotatePrefabKey);
        MAST_Settings.hotkey.rotatePrefabMod =
            (MAST_Hotkey_ScriptableObject.Modifier)EditorGUILayout.EnumPopup(
                "Modifier", MAST_Settings.hotkey.rotatePrefabMod);

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // ----------------------------------
        // Flip prefab
        // ----------------------------------
        EditorGUILayout.LabelField("Flip Prefab", EditorStyles.boldLabel);

        MAST_Settings.hotkey.flipPrefabKey =
            (KeyCode)EditorGUILayout.EnumPopup(
                "Key", MAST_Settings.hotkey.flipPrefabKey);
        MAST_Settings.hotkey.flipPrefabMod =
            (MAST_Hotkey_ScriptableObject.Modifier)EditorGUILayout.EnumPopup(
                "Modifier", MAST_Settings.hotkey.flipPrefabMod);

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        // Get hotkey settings object path from selected item in project view
        if (GUILayout.Button(
                new GUIContent("Load Hotkey Settings from selected file in Project",
                               "Use the selected (Hotkey Settings) file in project")))
        {
            string path = MAST_Asset_Loader.GetPathOfSelectedObjectTypeOf(typeof(MAST_Hotkey_ScriptableObject));

            if (path != "")
            {
                MAST_Settings.core.hotkeySettingsPath = path;
                MAST_Settings.Load_Hotkey_Settings();
            }
        }

        EditorGUILayout.EndScrollView();
    }
コード例 #13
0
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
    #region GUI Tab GUI
// ---------------------------------------------------------------------------
    private void GUIGUI()
    {
        // Verical scroll view for palette items
        gridScrollPos = EditorGUILayout.BeginScrollView(gridScrollPos);

        guiToolbarFoldout = EditorGUILayout.Foldout(guiToolbarFoldout, "Toolbar Settings");
        if (guiToolbarFoldout)
        {
            MAST_Settings.gui.toolbar.position =
                (MAST_GUI_ScriptableObject.ToolbarPos)EditorGUILayout.EnumPopup(
                    "Position", MAST_Settings.gui.toolbar.position);

            MAST_Settings.gui.toolbar.scale = EditorGUILayout.Slider(
                "Scale", MAST_Settings.gui.toolbar.scale, 0.5f, 1f);
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        guiPaletteFoldout = EditorGUILayout.Foldout(guiPaletteFoldout, "Palette Settings");
        if (guiPaletteFoldout)
        {
            MAST_Settings.gui.palette.bgColor =
                (MAST_GUI_ScriptableObject.PaleteBGColor)EditorGUILayout.EnumPopup(
                    "Background Color", MAST_Settings.gui.palette.bgColor);

            EditorGUILayout.Space();

            MAST_Settings.gui.palette.snapshotCameraPitch =
                Mathf.Clamp(EditorGUILayout.FloatField(new GUIContent(
                                                           "Thumbnail Pitch (0-360)", "Rotation around the Y axis"),
                                                       MAST_Settings.gui.palette.snapshotCameraPitch), 0f, 360f);

            MAST_Settings.gui.palette.snapshotCameraYaw =
                Mathf.Clamp(EditorGUILayout.FloatField(new GUIContent(
                                                           "Thumbnail Yaw (0-90)", "Rotation around the X axis"),
                                                       MAST_Settings.gui.palette.snapshotCameraYaw), 0f, 90f);
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        guiGridFoldout = EditorGUILayout.Foldout(guiGridFoldout, "Grid Settings");
        if (guiGridFoldout)
        {
            EditorGUILayout.LabelField("Grid Dimensions", EditorStyles.boldLabel);

            MAST_Settings.gui.grid.xzUnitSize =
                EditorGUILayout.FloatField(new GUIContent(
                                               "X/Z Unit Size", "Size of an individual grid square for snapping"),
                                           MAST_Settings.gui.grid.xzUnitSize);
            MAST_Settings.gui.grid.yUnitSize =
                EditorGUILayout.FloatField(new GUIContent(
                                               "Y Unit Size", "Y step for grid raising/lowering"),
                                           MAST_Settings.gui.grid.yUnitSize);
            MAST_Settings.gui.grid.cellCount =
                EditorGUILayout.IntField(new GUIContent(
                                             "Count (Center to Edge)", "Count of squares from center to each edge"),
                                         MAST_Settings.gui.grid.cellCount);

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Grid Cosmetics", EditorStyles.boldLabel);

            MAST_Settings.gui.grid.tintColor =
                EditorGUILayout.ColorField("Tint Color", MAST_Settings.gui.grid.tintColor);

            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        }

        // Get grid settings object path from selected item in project view
        if (GUILayout.Button(
                new GUIContent("Load GUI Settings from selected file in Project",
                               "Use the selected (GUI Settings) file in project")))
        {
            string path = MAST_Asset_Loader.GetPathOfSelectedObjectTypeOf(typeof(MAST_GUI_ScriptableObject));

            if (path != "")
            {
                MAST_Settings.core.guiSettingsPath = path;
                MAST_Settings.Load_GUI_Settings();
            }
        }

        EditorGUILayout.EndScrollView();
    }
コード例 #14
0
    // ---------------------------------------------------------------------------
    // MAST Window is Enabled
    // ---------------------------------------------------------------------------
    private void OnEnable()
    {
        //Debug.Log("Interface - On Enable");

        // Initialize Preference Manager
        MAST_Settings.Initialize();

        // Initialize the MAST State Manager
        MAST_Interface_Data_Manager.Initialize();


        // Set up deletegates so that OnScene is called automatically
        #if UNITY_2019_1_OR_NEWER
        SceneView.duringSceneGui -= this.OnScene;
        SceneView.duringSceneGui += this.OnScene;
        #else
        SceneView.onSceneGUIDelegate -= this.OnScene;
        SceneView.onSceneGUIDelegate += this.OnScene;
        #endif

        // Set up deletegates for exiting editor mode and returning to editor mode from play mode
        MAST_PlayModeStateListener.onExitEditMode  -= this.ExitEditMode;
        MAST_PlayModeStateListener.onExitEditMode  += this.ExitEditMode;
        MAST_PlayModeStateListener.onEnterEditMode -= this.EnterEditMode;
        MAST_PlayModeStateListener.onEnterEditMode += this.EnterEditMode;

        // Set scene to be updated by mousemovement
        wantsMouseMove = true;

        // If Enabled in Editor Mode
        if (!inPlayMode)
        {
            // Load icon textures
            if (iconGridToggle == null)
            {
                LoadImages();
            }

            // Load custom gui styles
            if (guiSkin == null)
            {
                guiSkin = MAST_Asset_Loader.GetGUISkin();
            }

            // Load interface data back from saved state
            MAST_Interface_Data_Manager.Load_Interface_State();

            // Create a new grid if needed
            if (MAST_Interface_Data_Manager.state.gridExists)
            {
                MAST_Grid_Manager.gridExists = true;
                MAST_Grid_Manager.ChangeGridVisibility();
            }

            // Change placement mode back to what was saved
            MAST_Placement_Interface.ChangePlacementMode(
                (MAST_Placement_Interface.PlacementMode)MAST_Settings.gui.toolbar.selectedDrawToolIndex);

            // TODO:  Reselect item in palette
            //MAST_Palette.selectedItemIndex = newSelectedPaletteItemIndex;

            // If palette images were lost due to serialization, load the palette from saved state
            if (MAST_Palette.ArePaletteImagesLost())
            {
                MAST_Interface_Data_Manager.Restore_Palette_Items();
            }
        }

        // If Enabled in Run Mode
        else
        {
            // Nothing so far, because everything is being triggered in ExitEditMode event method
        }
    }
コード例 #15
0
ファイル: MAST_Palette.cs プロジェクト: Trevor802/VII
 // ---------------------------------------------------------------------------
 // Prefab Palette
 // ---------------------------------------------------------------------------
 
 // Load all Prefabs from the selected folder and save the palette locally
 public static string LoadPrefabs(string defaultPath)
 {
     // ------------------------------------
     // Load Prefabs from Folder
     // ------------------------------------
     
     // Show choose folder dialog
     string chosenPath = EditorUtility.OpenFolderPanel("Choose the Folder that Contains your Prefabs",
         defaultPath, "");
     
     // Exit if no path was chosen (Cancel was clicked)
     if (chosenPath == "")
         return chosenPath;
     
     // Convert to project local path "Assets/..."
     string assetPath = chosenPath.Replace(Application.dataPath, "Assets");
     
     // Get the GUID of every file in that folder that is of the file type prefab
     string[] GUIDOfAllPrefabsInFolder =
         AssetDatabase.FindAssets("t:prefab", new[] { assetPath });
     
     // Create array to store the gameObjects
     prefabs = new GameObject[GUIDOfAllPrefabsInFolder.Length];
     
     // Create the string outside the loop so it is not recreated every loop
     string pathToPrefab;
     
     for (int index = GUIDOfAllPrefabsInFolder.Length - 1; index >= 0; index--)
     {
         // Convert GUID at current index to path string
         pathToPrefab = AssetDatabase.GUIDToAssetPath(GUIDOfAllPrefabsInFolder[index]);
         
         // Get gameObject at path
         prefabs[index] = (GameObject)AssetDatabase.LoadAssetAtPath(pathToPrefab, typeof(GameObject));
     }
     
     // ------------------------------------
     // Create Palette Items from Prefabs
     // ------------------------------------
     
     // Generate images of all prefabs and save to a Texture2D array
     texture2D = MAST_Asset_Loader.GetThumbnailCamera()
         .GetComponent<MAST_Snapshot_Camera_Component>()
         .GetThumbnails(prefabs);
     
     // Initialize guiContent and tooltip arrays
     guiContent = new GUIContent[prefabs.Length];
     tooltip = new string[prefabs.Length];
     
     // Create GUI Content from Images and Prefab names
     for (int i = 0; i < prefabs.Length; i++)
     {
         // Create tooltip from object name
         tooltip[i] = prefabs[i].name.Replace("_", "\n").Replace(" ", "\n");
         
         // Make sure texture has a transparent background
         texture2D[i].alphaIsTransparency = true;
         
         // Create GUIContent from texture and tooltip
         guiContent[i] = new GUIContent(texture2D[i], tooltip[i]);
     }
     
     return chosenPath;
 }