コード例 #1
0
    /// Called when the inspector GUI is to be drawn and handled.
    public override void OnInspectorGUI()
    {
        Generator.EditorReference = this;

        e2dStyles.Init();

        EditorGUIUtility.LookLikeControls();
        EditorGUILayout.Separator();

        // checks
        if (!e2dStyles.Inited)
        {
            EditorGUILayout.BeginVertical("HelpBox");
            if (e2dStyles.ErrorText != null) GUILayout.Label(e2dStrings.ERROR_CANT_FIND_ASSETS, e2dStyles.ErrorText);
            else GUILayout.Label(e2dStrings.ERROR_CANT_FIND_ASSETS);
            EditorGUILayout.EndVertical();
            return;
        }
        if (e2dEditorUtils.IsAnySceneToolSelected())
        {
            // the user selected some other tools
            mTool = e2dGeneratorTool.NONE;
        }

        // display toolbox
        GUI.changed = false;
        EditorGUILayout.BeginHorizontal();
        string[] toolOptions = e2dStrings.GENERATOR_TOOLS;
        mTool = (e2dGeneratorTool)GUILayout.Toolbar((int)mTool, toolOptions, GUILayout.MinWidth(0));
        EditorGUILayout.EndHorizontal();
        if (GUI.changed)
        {
            if (mTool == e2dGeneratorTool.CURVE)
            {
                mDebugHeightmap = null;
            }
            if (mTool != e2dGeneratorTool.NONE)
            {
                e2dEditorUtils.DeselectSceneTools();
                if (TerrainEditor) TerrainEditor.Tool = e2dTerrainTool.NONE;
                SceneView.RepaintAll();
            }
        }

        // tools
        switch (mTool)
        {
            case e2dGeneratorTool.CURVE:
                DrawTargetAreaTool();
                DrawCurveTool();
                break;
            case e2dGeneratorTool.SMOOTH:
                DrawTargetAreaTool();
                DrawSmoothTool();
                break;
            case e2dGeneratorTool.TEXTURE:
                DrawTargetAreaTool();
                DrawTextureTool();
                break;
            case e2dGeneratorTool.GRASS:
                DrawTargetAreaTool();
                DrawGrassTool();
                break;
        }

        EditorGUIUtility.LookLikeInspector();
    }
コード例 #2
0
    /// Called when the inspector GUI is to be drawn and handled.
    public override void OnInspectorGUI()
    {
        Generator.EditorReference = this;

        e2dStyles.Init();

        EditorGUIUtility.LookLikeControls();
        EditorGUILayout.Separator();


        // checks
        if (!e2dStyles.Inited)
        {
            EditorGUILayout.BeginVertical("HelpBox");
            if (e2dStyles.ErrorText != null)
            {
                GUILayout.Label(e2dStrings.ERROR_CANT_FIND_ASSETS, e2dStyles.ErrorText);
            }
            else
            {
                GUILayout.Label(e2dStrings.ERROR_CANT_FIND_ASSETS);
            }
            EditorGUILayout.EndVertical();
            return;
        }
        if (e2dEditorUtils.IsAnySceneToolSelected())
        {
            // the user selected some other tools
            mTool = e2dGeneratorTool.NONE;
        }


        // display toolbox
        GUI.changed = false;
        EditorGUILayout.BeginHorizontal();
        string[] toolOptions = e2dStrings.GENERATOR_TOOLS;
        mTool = (e2dGeneratorTool)GUILayout.Toolbar((int)mTool, toolOptions, GUILayout.MinWidth(0));
        EditorGUILayout.EndHorizontal();
        if (GUI.changed)
        {
            if (mTool == e2dGeneratorTool.CURVE)
            {
                mDebugHeightmap = null;
            }
            if (mTool != e2dGeneratorTool.NONE)
            {
                e2dEditorUtils.DeselectSceneTools();
                if (TerrainEditor)
                {
                    TerrainEditor.Tool = e2dTerrainTool.NONE;
                }
                SceneView.RepaintAll();
            }
        }

        // tools
        switch (mTool)
        {
        case e2dGeneratorTool.CURVE:
            DrawTargetAreaTool();
            DrawCurveTool();
            break;

        case e2dGeneratorTool.SMOOTH:
            DrawTargetAreaTool();
            DrawSmoothTool();
            break;

        case e2dGeneratorTool.TEXTURE:
            DrawTargetAreaTool();
            DrawTextureTool();
            break;

        case e2dGeneratorTool.GRASS:
            DrawTargetAreaTool();
            DrawGrassTool();
            break;
        }


        EditorGUIUtility.LookLikeInspector();
    }