示例#1
0
    private void Edit()
    {
        // Delegate to the PlacementDataEntryInspector
        var proxyModel = (ProxyModel)target;

        PlacementDataEntryInspector.Edit((PlacementDataAsset)proxyModel.PlacementDataAsset);
    }
示例#2
0
    public void DrawGUI()
    {
        EditorGUILayout.LabelField($"Editing {(_useSourceFile ? _file.SourceFile.FullName : _file.LayeredFSFile.FullName)}");

        if (GUILayout.Button("Save"))
        {
            Save();
        }

        using (var changeCheck = new EditorGUI.ChangeCheckScope())
        {
            _showGizmos = EditorGUILayout.ToggleLeft("Show Asset Gizmos", _showGizmos);
            using (new EditorGUI.DisabledScope(!_showGizmos))
            {
                _showAreaGizmos = EditorGUILayout.ToggleLeft("Show Area Gizmos", _showAreaGizmos);
            }

            if (changeCheck.changed)
            {
                EditorPrefs.SetBool($"{nameof(PlacementDataEditor)}_showGizmos", _showGizmos);
                EditorPrefs.SetBool($"{nameof(PlacementDataEditor)}_showAreaGizmos", _showAreaGizmos);
            }
        }

        using (var scroll = new EditorGUILayout.ScrollViewScope(_scrollPos))
        {
            _scrollPos = scroll.scrollPosition;
            foreach (var entry in _entries)
            {
                var  oldColor = GUI.color;
                bool editing  = IsEntrySelected(entry);

                using (new EditorGUILayout.HorizontalScope())
                {
                    if (editing)
                    {
                        GUILayout.Label(EditorGUIUtility.IconContent("d_editicon.sml", entry.ToString()),
                                        GUILayout.Width(20));
                        GUI.color = Color.cyan;
                    }
                    if (GUILayout.Button(entry.ToString(), EditorStyles.label))
                    {
                        if (editing)
                        {
                            var transformEntry = entry as IHasTransform;
                            if (transformEntry != null)
                            {
                                SceneView.lastActiveSceneView.pivot = transformEntry.Position;
                            }
                        }

                        PlacementDataEntryInspector.Edit(entry);
                    }
                }

                GUI.color = oldColor;
            }
        }
    }
示例#3
0
    public void DrawSceneGUI()
    {
        if (_sceneLabelStyle == null)
        {
            _sceneLabelStyle = new GUIStyle(EditorStyles.miniButton)
            {
                margin       = new RectOffset(),
                padding      = new RectOffset(),
                border       = new RectOffset(),
                overflow     = new RectOffset(),
                stretchWidth = true,
                alignment    = TextAnchor.MiddleCenter
            };
        }

        var oldCol   = GUI.color;
        var oldBgCol = GUI.backgroundColor;

        GUI.contentColor    = Color.cyan;
        GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f);
        foreach (var entry in _entries)
        {
            var transformAsset = entry as IHasTransform;
            if (transformAsset == null)
            {
                continue;
            }

            var  pos      = transformAsset.Position;
            bool selected = IsEntrySelected(entry);

            var areaAsset = entry as AreaAsset;
            if (areaAsset != null && (_showGizmos && _showAreaGizmos || selected))
            {
                var size          = areaAsset.Size;
                var size3D        = new Vector3(size.x, 3f, size.y);
                var rotatedSize3D = areaAsset.Rotation * size3D;

                var oldHandleColor = Handles.color;
                Handles.color = areaAsset.HandleColor;
                Handles.DrawWireCube(pos, rotatedSize3D);
                Handles.color = oldHandleColor;
            }

            if (selected)
            {
                if ((entry as CharaAsset)?.PreviewModel == null)
                {
                    Handles.Button(pos, transformAsset.Rotation, 0.2f, 0f, Handles.SphereHandleCap);
                }
            }
            else if (_showGizmos)
            {
                if (Handles.Button(pos, transformAsset.Rotation, 0.4f, 0.5f, Handles.ConeHandleCap))
                {
                    PlacementDataEntryInspector.Edit(entry);
                }

                Handles.Label(pos, transformAsset.ToString(), _sceneLabelStyle);
            }
        }

        GUI.contentColor    = oldCol;
        GUI.backgroundColor = oldBgCol;
    }