private void OnEnable()
        {
            m_CurrentProperty = serializedObject.FindProperty("current");
            m_ColorsProperty  = serializedObject.FindProperty("colors");

            m_GCAddColorSwatch = new GUIContent(IconUtility.GetIcon("PaintVertexColors/AddColor"), "Add Selected Color to Palette");
            m_GCRemoveSwatch   = new GUIContent(IconUtility.GetIcon("PaintVertexColors/Trashcan"));
        }
Exemplo n.º 2
0
            public static void Initialize()
            {
                deleteButtonStyle = new GUIStyle(GUI.skin.button);
                deleteButtonStyle.normal.background = IconUtility.GetIcon("PaintPrefabs/Delete");
                deleteButtonStyle.padding           = new RectOffset(0, 0, 0, 0);
                deleteButtonStyle.fixedHeight       = deleteButtonStyle.normal.background.width;
                deleteButtonStyle.fixedWidth        = deleteButtonStyle.normal.background.width;
                deleteButtonStyle.hover.background  = deleteButtonStyle.active.background = null;

                initialized = true;
            }
 void GenerateStaticGUIStyle()
 {
     s_StyleForColorSwatch                   = new GUIStyle(GUI.skin.FindStyle("IconButton"));
     s_StyleForColorSwatch.border            = new RectOffset(0, 0, 0, 0);
     s_StyleForColorSwatch.padding           = new RectOffset(0, 0, 0, 0);
     s_StyleForColorSwatch.margin            = new RectOffset(-1, -1, 0, 0);
     s_StyleForColorSwatch.richText          = false;
     s_StyleForColorSwatch.imagePosition     = ImagePosition.ImageOnly;
     s_StyleForColorSwatch.fixedHeight       = s_StyleForColorSwatch.fixedWidth = 0;
     s_StyleForColorSwatch.stretchHeight     = s_StyleForColorSwatch.stretchWidth = true;
     s_StyleForColorSwatch.alignment         = TextAnchor.MiddleCenter;
     s_StyleForColorSwatch.normal.background = IconUtility.GetIcon("PaintVertexColors/ColorSwatch");
 }
        void OnEnable()
        {
            if (!PrefUtility.VersionCheck())
            {
                PrefUtility.ClearPrefs();
            }

            PolybrushEditor.s_Instance = this;

            // Editor window setup
            titleContent   = new GUIContent("Polybrush");
            wantsMouseMove = true;
            minSize        = k_EditorWindowMinimumSize;

            m_BrushMirrorEditor = new MirrorSettingsEditor();

#if PROBUILDER_4_0_OR_NEWER
            if (ProBuilderBridge.ProBuilderExists())
            {
                ProBuilderBridge.SubscribeToSelectModeChanged(OnProBuilderSelectModeChanged);
            }
#endif

            m_GCToolmodeIcons = new GUIContent[]
            {
                EditorGUIUtility.TrIconContent(IconUtility.GetIcon("Toolbar/Sculpt"), "Sculpt on meshes"),
                EditorGUIUtility.TrIconContent(IconUtility.GetIcon("Toolbar/Smooth"), "Smooth mesh geometry"),
                EditorGUIUtility.TrIconContent(IconUtility.GetIcon("Toolbar/PaintVertexColors"), "Paint vertex colors on meshes"),
                EditorGUIUtility.TrIconContent(IconUtility.GetIcon("Toolbar/PaintPrefabs"), "Scatter Prefabs on meshes"),
                EditorGUIUtility.TrIconContent(IconUtility.GetIcon("Toolbar/PaintTextures"), "Paint textures on meshes"),
            };

#if UNITY_2019_1_OR_NEWER
            SceneView.duringSceneGui += OnSceneGUI;
#else
            SceneView.onSceneGUIDelegate += OnSceneGUI;
#endif
            Undo.undoRedoPerformed += UndoRedoPerformed;

            // force update the preview
            m_LastHoveredGameObject = null;

            EnsureBrushSettingsListIsValid();
            PopulateAvailableBrushList();

            SetTool(BrushTool.RaiseLower, false);

            Selection.selectionChanged -= OnSelectionChanged;
            Selection.selectionChanged += OnSelectionChanged;
        }
Exemplo n.º 5
0
        void OnEnable()
        {
            if (!PrefUtility.VersionCheck())
            {
                PrefUtility.ClearPrefs();
            }

            PolyEditor.s_Instance = this;

            // Editor window setup
            titleContent   = new GUIContent("Polybrush");
            wantsMouseMove = true;
            minSize        = k_EditorWindowMinimumSize;

            m_BrushMirrorEditor = new MirrorSettingsEditor();

#if PROBUILDER_4_0_OR_NEWER
            if (ProBuilderBridge.ProBuilderExists())
            {
                ProBuilderBridge.SubscribeToSelectModeChanged(OnProBuilderSelectModeChanged);
            }
#endif

            m_GCToolmodeIcons = new GUIContent[]
            {
                EditorGUIUtility.TrIconContent(IconUtility.GetIcon("Toolbar/Sculpt"), "Sculpt on meshes"),
                EditorGUIUtility.TrIconContent(IconUtility.GetIcon("Toolbar/Smooth"), "Smooth mesh geometry"),
                EditorGUIUtility.TrIconContent(IconUtility.GetIcon("Toolbar/PaintVertexColors"), "Paint vertex colors on meshes"),
                EditorGUIUtility.TrIconContent(IconUtility.GetIcon("Toolbar/PaintPrefabs"), "Scatter Prefabs on meshes"),
                EditorGUIUtility.TrIconContent(IconUtility.GetIcon("Toolbar/PaintTextures"), "Paint textures on meshes"),
            };

#if UNITY_2019_1_OR_NEWER
            SceneView.duringSceneGui += OnSceneGUI;
#else
            SceneView.onSceneGUIDelegate += OnSceneGUI;
#endif
            Undo.undoRedoPerformed += UndoRedoPerformed;

            // force update the preview
            m_LastHoveredGameObject = null;

            if (brushSettings == null)
            {
                if (brushSettingsAsset == null)
                {
                    brushSettingsAsset = AssetDatabase.LoadAssetAtPath <BrushSettings>(AssetDatabase.GUIDToAssetPath(EditorPrefs.GetString(k_BrushSettingsAssetPref, "")));
                }

                if (EditorPrefs.HasKey(k_BrushSettingsPref))
                {
                    brushSettings = ScriptableObject.CreateInstance <BrushSettings>();
                    JsonUtility.FromJsonOverwrite(EditorPrefs.GetString(k_BrushSettingsPref), brushSettings);
                    if (EditorPrefs.HasKey(k_BrushSettingsName))
                    {
                        brushSettings.name = EditorPrefs.GetString(k_BrushSettingsName);
                    }
                }
                else
                {
                    SetBrushSettings(brushSettingsAsset != null ? brushSettingsAsset : PolyEditorUtility.GetFirstOrNew <BrushSettings>());
                }
            }

            RefreshAvailableBrushes();

            SetTool(BrushTool.RaiseLower, false);

            Selection.selectionChanged -= OnSelectionChanged;
            Selection.selectionChanged += OnSelectionChanged;
        }