Exemple #1
0
        public override void OnInspectorGUI()
        {
            _navTileBanner.Draw();

            serializedObject.Update();

            // Multi editing not supported as it would not make sense, since every NavLink should be unique.
            using (new EditorGUI.DisabledGroupScope(targets.Length > 1))
            {
                EditorGUI.BeginChangeCheck();

                EditorGUILayout.PropertyField(_linkedTileProperty);

                if (EditorGUI.EndChangeCheck())
                {
                    // Record the NavLink dictionary for undo.
                    Undo.RecordObject(NavTileManager.Instance, Undo.GetCurrentGroupName());
                    TileBase newTile = (TileBase)_linkedTileProperty.objectReferenceValue;

                    // Callback for the tile change.
                    if (_linkedTileProperty.objectReferenceValue != Tile.LinkedTile)
                    {
                        Tile.OnTileChanged(Tile.LinkedTile, newTile);
                    }
                }
            }

            // Area index.
            EditorHelper.DrawCompressedPopup(_areaIndexProperty, NavTileManager.Instance.AreaManager.AllAreaNames);

            // Buttons.
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("View Links"))
            {
                NavTileWindow.OpenLinksTab();
            }

            if (GUILayout.Button("Edit Areas"))
            {
                NavTileWindow.OpenAreasTab();
            }
            GUILayout.EndHorizontal();

            serializedObject.ApplyModifiedProperties();
        }
Exemple #2
0
        /// <summary>
        /// Draws the custom inspector.
        /// </summary>
        public override void OnInspectorGUI()
        {
            _navTileBanner.Draw();

            DoTilePreview(Tile.sprite, Tile.color, Matrix4x4.identity);

            serializedObject.Update();

            EditorGUILayout.PropertyField(_spriteProperty);

            using (new EditorGUI.DisabledGroupScope(_spriteProperty.objectReferenceValue == null))
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Sprite Editor"))
                {
                    Selection.activeObject = _spriteProperty.objectReferenceValue;
                    EditorApplication.ExecuteMenuItem("Window/2D/Sprite Editor");
                }
                GUILayout.EndHorizontal();
            }

            EditorGUILayout.PropertyField(_colorProperty);
            EditorGUILayout.PropertyField(_colliderTypeProperty);
            EditorHelper.DrawCompressedPopup(_areaIndexProperty, NavTileManager.Instance.AreaManager.AllAreaNames);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Edit Areas"))
            {
                NavTileWindow.OpenAreasTab();
            }
            GUILayout.EndHorizontal();

            serializedObject.ApplyModifiedProperties();
        }
Exemple #3
0
        /// <summary>
        /// Draw the inspector.
        /// </summary>
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            _bannerTexture.Draw();

            EditorGUILayout.LabelField("Behavior", EditorStyles.boldLabel);
            EditorHelper.DrawProperty(_autoTraversePathProperty, new PropertyDrawingOptions().DoTooltip(AUTO_TRAVERSE_PATH_TOOLTIP));

            EditorGUILayout.Space();

            // Fields.
            EditorGUILayout.LabelField("Pathfinding", EditorStyles.boldLabel);
            DrawAreaMask();

            EditorGUI.BeginChangeCheck();
            _agentTypeProperty.intValue = EditorGUILayout.Popup("Agent Type", _agentTypeProperty.intValue, NavTileManager.Instance.AgentManager.NamedAgents.ToArray());

            EditorHelper.DrawProperty(_speedProperty);

            if (EditorGUI.EndChangeCheck())
            {
                _speedProperty.floatValue = Mathf.Max(0, _speedProperty.floatValue);
            }

            EditorHelper.DrawProperty(_diagonalAllowedProperty);
            if (!_diagonalAllowedProperty.boolValue)
            {
                _cutCornersProperty.boolValue = false;
            }
            EditorHelper.DrawProperty(_cutCornersProperty, new PropertyDrawingOptions().DoReadOnly(!_diagonalAllowedProperty.boolValue));
            EditorHelper.DrawProperty(_ignoreTileCostProperty);

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Conflict Handling", EditorStyles.boldLabel);
            if (NavTileManager.Instance.PipelineManager.AlgorithmType == typeof(AStar).AssemblyQualifiedName)
            {
                _conflictOptionProperty.enumValueIndex = EditorGUILayout.Popup("Conflict Option", _conflictOptionProperty.enumValueIndex, _conflictOptionProperty.enumDisplayNames);

                if ((NavTileAgent.EConflictOptions)_conflictOptionProperty.enumValueIndex >= NavTileAgent.EConflictOptions.WaitOnTraversingAgent)
                {
                    EditorHelper.DrawProperty(_waitAfterFreeTileProperty);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("The selected pathfinding algorithm does not support conflict handling. To utilize conflict handling, select A* in the pipeline options.", MessageType.Warning);
                if (GUILayout.Button("Open Pipeline Options"))
                {
                    NavTileWindow.OpenPipelineTab();
                }
            }

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Debug", EditorStyles.boldLabel);
            EditorHelper.DrawProperty(_debugEnabledProperty, new PropertyDrawingOptions().DoLabel("Display Calculated Path").DoTooltip("Whether the calculated path should be displayed using gizmos."));
            if (_debugEnabledProperty.boolValue)
            {
                EditorHelper.DrawProperty(_debugLineColorProperty, new PropertyDrawingOptions().DoLabel("Path Color"));
            }

            EditorGUILayout.Space();

            // Animation settings.
            if (_animationSettingsFoldoutOpen = EditorGUILayout.BeginFoldoutHeaderGroup(_animationSettingsFoldoutOpen, "Animation Settings"))
            {
                EditorGUI.indentLevel++;
                DrawAnimationSettings();
                EditorGUILayout.Space();
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();

            // Area settings.
            if (_areaSettingsFoldoutOpen = EditorGUILayout.BeginFoldoutHeaderGroup(_areaSettingsFoldoutOpen, "Area Settings"))
            {
                EditorGUI.indentLevel++;
                DrawAreaSettings();
                EditorGUILayout.Space();
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();

            // Path callbacks.
            if (_pathCallbacksFoldoutOpen = EditorGUILayout.BeginFoldoutHeaderGroup(_pathCallbacksFoldoutOpen, "Path Callbacks"))
            {
                EditorGUI.indentLevel++;
                DrawPathCallbacks();
                EditorGUILayout.Space();
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();

            SaveEditorPrefs();
            serializedObject.ApplyModifiedProperties();
        }