コード例 #1
0
        private void UpdateDynamicsPanel(float width)
        {
            if (nextSelectingBrush != selectingBrush && Event.current.type == EventType.Layout)
            {
                selectingBrush = nextSelectingBrush;
            }

            EditorGUILayout.BeginVertical(GUILayout.Width(width));
            EditorGUILayout.Separator();
            DrawBrushTop(width);
            EditorGUILayout.Separator();

            if (selectingBrush == true)
            {
                paintBrushesScrollPosition = GUILayout.BeginScrollView(paintBrushesScrollPosition, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                UpdatePaintBrushesBrowser(width);
                GUILayout.EndScrollView();
            }
            else
            {
                dynamicsScrollPosition = GUILayout.BeginScrollView(dynamicsScrollPosition, GUILayout.Width(200));
                P3dHelper.BeginLabelWidth(50);
                UpdateDynamicsBrushPanel();
                P3dHelper.EndLabelWidth();
                GUILayout.EndScrollView();
            }
            EditorGUILayout.EndVertical();
        }
コード例 #2
0
        private void DrawConfigTab()
        {
            configScrollPosition = GUILayout.BeginScrollView(configScrollPosition, GUILayout.ExpandHeight(true));
            P3dHelper.BeginLabelWidth(100);
            Settings.ColorGroup = EditorGUILayout.IntField("Color Group", Settings.ColorGroup);
            Settings.IconSize   = EditorGUILayout.IntSlider("Icon Size", Settings.IconSize, 32, 256);
            EditorGUILayout.BeginHorizontal();
            Settings.StateLimit = EditorGUILayout.IntField("State Limit", Settings.StateLimit);
            if (GUILayout.Button(new GUIContent("Apply", "Apply this undo/redo state limit to all P3dPaintableTexture components in the scene?"), EditorStyles.miniButton, GUILayout.ExpandWidth(false)) == true)
            {
                if (EditorUtility.DisplayDialog("Are you sure?", "This will apply this StateLimit to all P3dPaintableTexture components in the scene.", "OK") == true)
                {
                    ApplyStateLimit();
                }
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Clear Settings") == true)
            {
                if (EditorUtility.DisplayDialog("Are you sure?", "This will reset all editor painting settings to default.", "OK") == true)
                {
                    ClearSettings();
                }
            }
            GUILayout.EndScrollView();
        }
コード例 #3
0
        private void UpdateDynamicsPanel()
        {
            P3dHelper.BeginLabelWidth(50);
            settings.PaintScale = LogSlider("Scale", settings.PaintScale, -2, 4);
            settings.PaintTile  = LogSlider("Tiling", settings.PaintTile, -2, 4);

            EditorGUILayout.Separator();

            settings.PaintColor   = EditorGUILayout.ColorField("Color", settings.PaintColor);
            settings.PaintColor.r = Slider("Red", settings.PaintColor.r, 0.0f, 1.0f);
            settings.PaintColor.g = Slider("Green", settings.PaintColor.g, 0.0f, 1.0f);
            settings.PaintColor.b = Slider("Blue", settings.PaintColor.b, 0.0f, 1.0f);
            settings.PaintColor.a = Slider("Alpha", settings.PaintColor.a, 0.0f, 1.0f);

            float h, s, v; Color.RGBToHSV(settings.PaintColor, out h, out s, out v);

            h = Slider("Hue", h, 0.0f, 1.0f);
            s = Slider("Saturation", s, 0.0f, 1.0f);
            v = Slider("Value", v, 0.0f, 1.0f);

            var newColor = Color.HSVToRGB(h, s, v);

            settings.PaintColor.r = newColor.r;
            settings.PaintColor.g = newColor.g;
            settings.PaintColor.b = newColor.b;

            P3dHelper.EndLabelWidth();
        }
コード例 #4
0
        private void DrawConfig()
        {
            configScrollPosition = GUILayout.BeginScrollView(configScrollPosition, GUILayout.ExpandHeight(true));
            P3dHelper.BeginLabelWidth(100);
            Settings.ColorGroup = EditorGUILayout.IntField("Color Group", Settings.ColorGroup);
            Settings.IconSize   = EditorGUILayout.IntSlider("Icon Size", Settings.IconSize, 32, 256);
            EditorGUILayout.BeginHorizontal();
            Settings.StateLimit = EditorGUILayout.IntField("State Limit", Settings.StateLimit);
            if (GUILayout.Button(new GUIContent("Apply", "Apply this undo/redo state limit to all P3dPaintableTexture components in the scene?"), EditorStyles.miniButton, GUILayout.ExpandWidth(false)) == true)
            {
                if (EditorUtility.DisplayDialog("Are you sure?", "This will apply this StateLimit to all P3dPaintableTexture components in the scene.", "ok") == true)
                {
                    ApplyStateLimit();
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();

            EditorGUILayout.LabelField("Move", EditorStyles.boldLabel);
            Settings.MoveSpeed    = EditorGUILayout.FloatField("Speed", Settings.MoveSpeed);
            Settings.MoveForward  = (KeyCode)EditorGUILayout.EnumPopup("Forward", Settings.MoveForward);
            Settings.MoveBackward = (KeyCode)EditorGUILayout.EnumPopup("Backward", Settings.MoveBackward);
            Settings.MoveLeft     = (KeyCode)EditorGUILayout.EnumPopup("Left", Settings.MoveLeft);
            Settings.MoveRight    = (KeyCode)EditorGUILayout.EnumPopup("Right", Settings.MoveRight);
            P3dHelper.EndLabelWidth();
            GUILayout.EndScrollView();
        }
コード例 #5
0
        private void UpdateScenePanel()
        {
            P3dHelper.BeginLabelWidth(60.0f);
            cameraOrigin   = EditorGUILayout.Vector3Field("Origin", cameraOrigin);
            cameraDistance = Mathf.Max(0.0001f, EditorGUILayout.FloatField("Distance", cameraDistance));

            previewUtil.ambientColor = EditorGUILayout.ColorField("Am Color", previewUtil.ambientColor);

            DrawLightData(settings.Light0);
            DrawLightData(settings.Light1);
            P3dHelper.EndLabelWidth();
        }
コード例 #6
0
 private void UpdateSettingsPanel()
 {
     P3dHelper.BeginLabelWidth(100);
     settings.Environment        = (ReflectionProbe)EditorGUILayout.ObjectField("Environment", settings.Environment, typeof(ReflectionProbe), true);
     settings.DefaultTextureSize = EditorGUILayout.IntField("Default Size", settings.DefaultTextureSize);
     settings.TurnSensitivity    = EditorGUILayout.FloatField("Turn Sensitivity", settings.TurnSensitivity);
     settings.ZoomSensitivity    = EditorGUILayout.FloatField("Zoom Sensitivity", settings.ZoomSensitivity);
     settings.UndoMegabytes      = EditorGUILayout.IntField("Undo Megabytes", settings.UndoMegabytes);
     settings.ExportFormat       = EditorGUILayout.TextField("Export Format", settings.ExportFormat);
     settings.ThumbnailSize      = EditorGUILayout.IntSlider("Thumbnail Size", settings.ThumbnailSize, 32, 256);
     settings.ColorModifies      = EditorGUILayout.IntField(new GUIContent("Color Modifies", "The texture group that will be tinted by the current color (e.g. Albedo = -199)."), settings.ColorModifies);
     P3dHelper.EndLabelWidth();
 }
コード例 #7
0
        private void UpdateDynamicsBrushPanel()
        {
            P3dHelper.BeginLabelWidth(50);
            settings.PaintMode    = (ModeType)EditorGUILayout.EnumPopup("Mode", settings.PaintMode);
            settings.PaintScale   = LogSlider("Scale", settings.PaintScale, -4, 4);
            settings.PaintOpacity = EditorGUILayout.Slider("Opacity", settings.PaintOpacity, 0.0f, 1.0f);
            settings.PaintAngle   = EditorGUILayout.Slider("Angle", settings.PaintAngle, -180.0f, 180.0f);

            EditorGUILayout.Separator();

            GUILayout.FlexibleSpace();

            paintBrushData.Modifiers.DrawEditorLayout(false, "Angle", "Opacity", "Position", "Radius");
            P3dHelper.EndLabelWidth();
        }
コード例 #8
0
        private void DrawPaint()
        {
            if (selectingTool == true)
            {
                DrawTool(); return;
            }

            if (selectingMaterial == true)
            {
                DrawMaterial(); return;
            }

            if (selectingShape == true)
            {
                DrawShape(); return;
            }

            paintScrollPosition = GUILayout.BeginScrollView(paintScrollPosition, GUILayout.ExpandHeight(true));
            DrawTop();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawRadius();
            P3dHelper.EndLabelWidth();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawColor();
            P3dHelper.EndLabelWidth();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawCamera();
            P3dHelper.EndLabelWidth();
            GUILayout.EndScrollView();

            GUILayout.FlexibleSpace();

            if (Application.isPlaying == false)
            {
                EditorGUILayout.HelpBox("You must enter play mode to begin painting.", MessageType.Warning);
            }

            UpdatePaint();
        }
コード例 #9
0
        private void UpdateClonersPanel()
        {
            for (var i = 0; i < scene.Cloners.Count; i++)
            {
                EditorGUILayout.Space();

                var cloner  = scene.Cloners[i];
                var matRect =
                    EditorGUILayout.BeginVertical(GetSelectableStyle(currentCloners.Contains(cloner), true));
                P3dHelper.BeginLabelWidth(60.0f);
                if (currentCloners.Contains(cloner) == true)
                {
                    EditorGUILayout.BeginHorizontal();
                    P3dHelper.BeginColor(scene.MatNameValid(cloner.Name) == false);
                    cloner.Name = EditorGUILayout.TextField(cloner.Name);
                    P3dHelper.EndColor();
                    if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20)) == true && EditorUtility.DisplayDialog("Are you sure?", "This will delete the current cloner from the paint scene.", "Delete") == true)
                    {
                        scene.Cloners.RemoveAt(i--); P3dHelper.ClearControl();
                    }
                    EditorGUILayout.EndHorizontal();
                    cloner.Position = EditorGUILayout.Vector3Field("Position", cloner.Position);
                    cloner.Euler    = EditorGUILayout.Vector3Field("Euler", cloner.Euler);
                    cloner.Flip     = EditorGUILayout.Toggle("Flip", cloner.Flip);
                }
                else
                {
                    EditorGUILayout.LabelField(cloner.Name);
                }
                P3dHelper.EndLabelWidth();
                EditorGUILayout.EndVertical();

                if (Event.current.type == EventType.MouseDown && matRect.Contains(Event.current.mousePosition) == true)
                {
                    if (currentCloners.Remove(cloner) == false)
                    {
                        currentCloners.Add(cloner);
                    }

                    P3dHelper.ClearControl();
                }
            }

            if (GUILayout.Button("Add Cloner") == true)
            {
                currentCloners.Add(scene.AddCloner("New Cloner", Vector3.zero, Vector3.zero)); P3dHelper.ClearControl();
            }
        }
コード例 #10
0
        private bool DrawAddableObject(GameObject go, Material[] materials)
        {
            var add = false;

            GUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.ObjectField(go, typeof(GameObject), true);
            EditorGUI.EndDisabledGroup();

            tempTemplates.Clear();

            for (var i = 0; i < materials.Length; i++)
            {
                var material  = materials[i];
                var templates = P3dShaderTemplate.GetTemplates(material != null ? material.shader : null);
                var slot      = GetTempObj(go, i);

                if (templates.Contains(slot.Template) == false)
                {
                    slot.Template = templates.Count > 0 ? templates[0] : null;
                }

                GUILayout.BeginVertical(EditorStyles.helpBox);
                P3dHelper.BeginLabelWidth(60.0f);
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.ObjectField("Material", material, typeof(Material), true);
                EditorGUI.EndDisabledGroup();
                P3dHelper.BeginColor(slot.Template == null);
                P3dShaderTemplate_Editor.DrawDropdown("Template", material, slot);
                P3dHelper.EndColor();
                P3dHelper.EndLabelWidth();
                GUILayout.EndVertical();

                tempTemplates.Add(slot.Template);
            }

            if (GUILayout.Button("Add") == true)
            {
                add = true;
            }
            GUILayout.EndVertical();

            return(add);
        }
コード例 #11
0
        private void UpdateLayersPanel()
        {
            GUILayout.FlexibleSpace();

            for (var i = scene.Layers.Count - 1; i >= 0; i--)
            {
                if (i < scene.Layers.Count - 1)
                {
                    EditorGUILayout.Space();
                }

                var layer     = scene.Layers[i];
                var layerRect =
                    EditorGUILayout.BeginVertical(GetSelectableStyle(layer == currentLayer, true));
                P3dHelper.BeginLabelWidth(60.0f);
                GUILayout.BeginHorizontal();
                if (layer == currentLayer)
                {
                    EditorGUILayout.BeginHorizontal();
                    layer.Name = EditorGUILayout.TextField(layer.Name);
                    if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20)) == true && EditorUtility.DisplayDialog("Are you sure?", "This will delete the current layer from the paint window.", "Delete") == true)
                    {
                        scene.RemoveLayer(layer); P3dHelper.ClearControl();
                    }
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.Label(layer.Name);
                }
                GUILayout.EndHorizontal();

                if (layer == currentLayer)
                {
                    EditorGUI.BeginChangeCheck();

                    layer.Opacity = EditorGUILayout.Slider("Opacity", layer.Opacity, 0.0f, 1.0f);

                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        UpdatePaintedMats();
                    }

                    //foreach (var image in layer.Images)
                    //{
                    //	EditorGUILayout.ObjectField(image.Current, typeof(Texture), true);
                    //}
                }
                P3dHelper.EndLabelWidth();
                GUILayout.EndVertical();

                if (Event.current.type == EventType.MouseDown && layerRect.Contains(Event.current.mousePosition) == true)
                {
                    currentLayer = layer; P3dHelper.ClearControl();
                }
            }

            if (GUILayout.Button("Add Layer") == true)
            {
                currentLayer = scene.AddLayer(); P3dHelper.ClearControl();
            }
        }
コード例 #12
0
        private void UpdatePaintPanel(float width)
        {
            if (nextSelectingMaterial != selectingMaterial && Event.current.type == EventType.Layout)
            {
                selectingMaterial = nextSelectingMaterial;
            }

            EditorGUILayout.BeginVertical(GUILayout.Width(width));
            EditorGUILayout.Separator();
            DrawMaterialTop(width);
            EditorGUILayout.Separator();

            if (selectingMaterial == true)
            {
                paintMaterialsScrollPosition = GUILayout.BeginScrollView(paintMaterialsScrollPosition, GUILayout.Width(width));
                UpdatePaintMaterialsBrowser(width);
                GUILayout.EndScrollView();
            }
            else
            {
                paintMaterialsScrollPosition = GUILayout.BeginScrollView(paintMaterialsScrollPosition, GUILayout.Width(width));
                P3dHelper.BeginLabelWidth(50);
                settings.PaintTile = LogSlider("Tiling", settings.PaintTile, -2, 4);

                var color = settings.PaintColor;

                color   = EditorGUILayout.ColorField("Color", color);
                color.r = Slider("Red", color.r, 0.0f, 1.0f);
                color.g = Slider("Green", color.g, 0.0f, 1.0f);
                color.b = Slider("Blue", color.b, 0.0f, 1.0f);
                color.a = Slider("Alpha", color.a, 0.0f, 1.0f);

                float h, s, v; Color.RGBToHSV(color, out h, out s, out v);

                h = Slider("Hue", h, 0.0f, 1.0f);
                s = Slider("Saturation", s, 0.0f, 1.0f);
                v = Slider("Value", v, 0.0f, 1.0f);

                var newColor = Color.HSVToRGB(h, s, v);

                color.r = newColor.r;
                color.g = newColor.g;
                color.b = newColor.b;

                settings.PaintColor = color;

                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Normal", EditorStyles.boldLabel);
                settings.PaintNormalFront = EditorGUILayout.Slider("Front", settings.PaintNormalFront, 0.0f, 2.0f);
                settings.PaintNormalBack  = EditorGUILayout.Slider("Back", settings.PaintNormalBack, 0.0f, 2.0f);
                settings.PaintNormalFade  = EditorGUILayout.Slider("Fade", settings.PaintNormalFade, 0.001f, 0.5f);
                P3dHelper.EndLabelWidth();

                GUILayout.FlexibleSpace();

                P3dHelper.BeginLabelWidth(50);
                CompileLayerGroups();
                DrawLayerGroups();
                P3dHelper.EndLabelWidth();
                GUILayout.EndScrollView();
            }
            EditorGUILayout.EndVertical();
        }
コード例 #13
0
        private void UpdateObjectsPanel()
        {
            if (Selection.gameObjects.Length == 0 && scene.Objs.Count == 0)
            {
                EditorGUILayout.HelpBox("Select a GameObject with a MesFilter+MeshRenderer or SkinnedMeshRenderer.", MessageType.Info);
            }

            // Mark
            tempObjs.ForEach(t => t.Dirty = true);

            roots.Clear();

            foreach (var transform in Selection.transforms)
            {
                RunRoots(transform);
            }

            foreach (var root in roots)
            {
                if (scene.ObjExists(root) == false)
                {
                    var mf  = root.GetComponent <MeshFilter>();
                    var mr  = root.GetComponent <MeshRenderer>();
                    var smr = root.GetComponent <SkinnedMeshRenderer>();

                    if (mf != null && mr != null && mf.sharedMesh != null)
                    {
                        if (DrawAddableObject(root.gameObject, mr.sharedMaterials) == true)
                        {
                            scene.AddObj(root, mf.sharedMesh, root.position, root.rotation, root.lossyScale, mr.sharedMaterials, tempTemplates.ToArray(), settings.DefaultTextureSize);
                        }
                    }
                    else if (smr != null && smr.sharedMesh != null)
                    {
                        if (DrawAddableObject(root.gameObject, smr.sharedMaterials) == true)
                        {
                            scene.AddObj(root, smr.sharedMesh, root.position, root.rotation, root.lossyScale, smr.sharedMaterials, tempTemplates.ToArray(), settings.DefaultTextureSize);
                        }
                    }
                }
            }

            // Sweep
            tempObjs.RemoveAll(t => t.Dirty == true);

            EditorGUILayout.Separator();

            for (var i = 0; i < scene.Objs.Count; i++)
            {
                if (i > 0)
                {
                    EditorGUILayout.Space();
                }

                var obj     = scene.Objs[i];
                var objRect =
                    EditorGUILayout.BeginVertical(GetSelectableStyle(obj == currentObj, true));
                P3dHelper.BeginLabelWidth(60.0f);
                if (obj == currentObj)
                {
                    EditorGUILayout.BeginHorizontal();
                    obj.Name = EditorGUILayout.TextField(obj.Name);
                    if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20)) == true && EditorUtility.DisplayDialog("Are you sure?", "This will delete the current layer from the paint window.", "Delete") == true)
                    {
                        scene.RemoveObj(obj); i--; P3dHelper.ClearControl();
                    }
                    EditorGUILayout.EndHorizontal();

                    obj.Mesh      = (Mesh)EditorGUILayout.ObjectField("Mesh", obj.Mesh, typeof(Mesh), true);
                    obj.Paintable = EditorGUILayout.Toggle("Paintable", obj.Paintable);
                    obj.Coord     = (P3dCoord)EditorGUILayout.EnumPopup("Coord", obj.Coord);
                    obj.Transform = (Transform)EditorGUILayout.ObjectField("Transform", obj.Transform, typeof(Transform), true);
                    obj.Preview   = (Transform)EditorGUILayout.ObjectField("Preview", obj.Preview, typeof(Transform), true);

                    if (obj.Transform == null)
                    {
                        obj.Position = EditorGUILayout.Vector3Field("Position", obj.Position);

                        EditorGUI.BeginChangeCheck();
                        var newRot = EditorGUILayout.Vector3Field("Rotation", obj.Rotation.eulerAngles);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            obj.Rotation = Quaternion.Euler(newRot);
                        }

                        obj.Scale = EditorGUILayout.Vector3Field("Scale", obj.Scale);
                    }
                    else
                    {
                        var smr = obj.Transform.GetComponent <SkinnedMeshRenderer>();

                        if (smr != null && smr.sharedMesh != null)
                        {
                            if (obj.BakedMesh == null)
                            {
                                if (GUILayout.Button("Bake Pose") == true)
                                {
                                    BakeMesh(smr, ref obj.BakedMesh, false);
                                }

                                if (GUILayout.Button("Bake Pose + Scale") == true)
                                {
                                    BakeMesh(smr, ref obj.BakedMesh, true);
                                }
                            }
                            else
                            {
                                if (GUILayout.Button("Update Pose") == true)
                                {
                                    BakeMesh(smr, ref obj.BakedMesh, obj.BakedMesh.name == "SCALED");
                                }

                                if (GUILayout.Button("Reset Pose") == true)
                                {
                                    DestroyImmediate(obj.BakedMesh);

                                    obj.BakedMesh = null;
                                }
                            }
                        }
                    }

                    if (GUILayout.Button("Center Camera") == true)
                    {
                        cameraOrigin = obj.Position;
                    }

                    EditorGUILayout.Separator();

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Materials", EditorStyles.boldLabel);
                    if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(20)) == true)
                    {
                        obj.MatIds.Add(-1);
                    }
                    EditorGUILayout.EndHorizontal();

                    for (var j = 0; j < obj.MatIds.Count; j++)
                    {
                        var matId = obj.MatIds[j];
                        var rect  = P3dHelper.Reserve(); rect.xMin += 10;
                        var mat   = scene.GetMat(matId);

                        if (GUI.Button(rect, mat != null ? mat.Name : "", EditorStyles.popup) == true)
                        {
                            var menu = new GenericMenu();

                            for (var k = 0; k < scene.Mats.Count; k++)
                            {
                                var setObj = obj;
                                var setIdx = j;
                                var setMat = scene.Mats[k];

                                menu.AddItem(new GUIContent(setMat.Name), setMat == mat, () => setObj.MatIds[setIdx] = setMat.Id);
                            }

                            var remObj = obj;
                            var remIdx = j;

                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("Remove"), false, () => remObj.MatIds.RemoveAt(remIdx));

                            menu.DropDown(rect);
                        }
                    }
                }
                else
                {
                    EditorGUILayout.LabelField(obj.Name);
                }
                P3dHelper.EndLabelWidth();
                EditorGUILayout.EndVertical();

                if (Event.current.type == EventType.MouseDown && objRect.Contains(Event.current.mousePosition) == true)
                {
                    currentObj = obj; P3dHelper.ClearControl();
                }
            }
        }
コード例 #14
0
        private void DrawCameraTab()
        {
            cameraScrollPosition = GUILayout.BeginScrollView(cameraScrollPosition, GUILayout.ExpandHeight(true));
            EditorGUILayout.HelpBox("This allows you to control the Game view camera. Keep in mind this will not work if your camera already has controls from another source.", MessageType.Info);

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            EditorGUILayout.LabelField("Controls", EditorStyles.boldLabel);
            Settings.MoveSpeed    = EditorGUILayout.FloatField("Speed", Settings.MoveSpeed);
            Settings.MoveForward  = (KeyCode)EditorGUILayout.EnumPopup("Forward", Settings.MoveForward);
            Settings.MoveBackward = (KeyCode)EditorGUILayout.EnumPopup("Backward", Settings.MoveBackward);
            Settings.MoveLeft     = (KeyCode)EditorGUILayout.EnumPopup("Left", Settings.MoveLeft);
            Settings.MoveRight    = (KeyCode)EditorGUILayout.EnumPopup("Right", Settings.MoveRight);
            Settings.Rotate       = (KeyCode)EditorGUILayout.EnumPopup("Rotate", Settings.Rotate);
            Settings.Pan          = (KeyCode)EditorGUILayout.EnumPopup("Pan", Settings.Pan);
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.TextField("Paint", "Mouse 0", EditorStyles.popup);
            EditorGUILayout.TextField("Zoom", "Mouse Wheel", EditorStyles.popup);
            EditorGUILayout.TextField("Move Pivot", "Double Click (Right / Middle)", EditorStyles.popup);
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.Separator();

            Settings.OverrideCamera = EditorGUILayout.Toggle("Override Camera", Settings.OverrideCamera);

            if (Settings.OverrideCamera == true)
            {
                EditorGUI.indentLevel++;
                Settings.Distance  = LogSlider("Distance", Settings.Distance, -4, 4);
                Settings.Observer  = (Transform)EditorGUILayout.ObjectField("Root", Settings.Observer, typeof(Transform), true);
                Settings.ShowPivot = EditorGUILayout.Toggle("Show Pivot", Settings.ShowPivot);

                if (GUI.Button(EditorGUI.IndentedRect(P3dHelper.Reserve()), "Snap To Scene View", EditorStyles.miniButton) == true)
                {
                    var camA = Camera.main;

                    if (camA != null && SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera != null)
                    {
                        var camB = SceneView.lastActiveSceneView.camera;

                        camA.transform.position = camB.transform.position;
                        camA.transform.rotation = camB.transform.rotation;
                    }
                }
                EditorGUI.indentLevel--;

                if (toolInstance != null && toolInstance.CameraMovedUnexpectedly == true)
                {
                    EditorGUILayout.HelpBox("The camera moved unexpectedly. Mabe your scene already has camera controls?", MessageType.Warning);
                }
            }
            P3dHelper.EndLabelWidth();
            GUILayout.EndScrollView();

            GUILayout.FlexibleSpace();

            if (Application.isPlaying == false)
            {
                EditorGUILayout.HelpBox("You must enter play mode to move the Game camera.", MessageType.Warning);
            }
        }
コード例 #15
0
        private void UpdateObjectsPanel()
        {
            if (Selection.gameObjects.Length == 0 && scene.Objs.Count == 0)
            {
                EditorGUILayout.HelpBox("Select a GameObject with a MesFilter+MeshRenderer or SkinnedMeshRenderer.", MessageType.Info);
            }

            // Mark
            tempObjs.ForEach(t => t.Dirty = true);

            foreach (var go in Selection.gameObjects)
            {
                if (scene.ObjExists(go.transform) == false)
                {
                    var mf = go.GetComponent <MeshFilter>();
                    var mr = go.GetComponent <MeshRenderer>();

                    if (mf != null && mr != null && mf.sharedMesh != null)
                    {
                        GUILayout.BeginVertical(EditorStyles.helpBox);
                        EditorGUI.BeginDisabledGroup(true);
                        EditorGUILayout.ObjectField(go, typeof(GameObject), true);
                        EditorGUI.EndDisabledGroup();

                        var materials = mr.sharedMaterials;

                        tempTemplates.Clear();

                        for (var i = 0; i < materials.Length; i++)
                        {
                            var material  = materials[i];
                            var templates = P3dShaderTemplate.GetTemplates(material != null ? material.shader : null);
                            var slot      = GetTempObj(go, i);

                            if (templates.Contains(slot.Template) == false)
                            {
                                slot.Template = templates.Count > 0 ? templates[0] : null;
                            }

                            GUILayout.BeginVertical(EditorStyles.helpBox);
                            P3dHelper.BeginLabelWidth(60.0f);
                            EditorGUI.BeginDisabledGroup(true);
                            EditorGUILayout.ObjectField("Material", material, typeof(Material), true);
                            EditorGUI.EndDisabledGroup();
                            P3dHelper.BeginColor(slot.Template == null);
                            P3dShaderTemplate_Editor.DrawDropdown("Template", material, slot);
                            P3dHelper.EndColor();
                            P3dHelper.EndLabelWidth();
                            GUILayout.EndVertical();

                            tempTemplates.Add(slot.Template);
                        }

                        if (GUILayout.Button("Add") == true)
                        {
                            scene.AddObj(go.transform, mf.sharedMesh, go.transform.position, go.transform.rotation, go.transform.lossyScale, materials, tempTemplates.ToArray(), settings.DefaultTextureSize);
                        }
                        GUILayout.EndVertical();
                    }
                }
            }

            // Sweep
            tempObjs.RemoveAll(t => t.Dirty == true);

            EditorGUILayout.Separator();

            for (var i = 0; i < scene.Objs.Count; i++)
            {
                if (i > 0)
                {
                    EditorGUILayout.Space();
                }

                var obj     = scene.Objs[i];
                var objRect =
                    EditorGUILayout.BeginVertical(GetSelectableStyle(obj == currentObj, true));
                P3dHelper.BeginLabelWidth(60.0f);
                if (obj == currentObj)
                {
                    EditorGUILayout.BeginHorizontal();
                    obj.Name = EditorGUILayout.TextField(obj.Name);
                    if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20)) == true && EditorUtility.DisplayDialog("Are you sure?", "This will delete the current layer from the paint window.", "Delete") == true)
                    {
                        scene.RemoveObj(obj); i--; P3dHelper.ClearControl();
                    }
                    EditorGUILayout.EndHorizontal();

                    obj.Mesh      = (Mesh)EditorGUILayout.ObjectField("Mesh", obj.Mesh, typeof(Mesh), true);
                    obj.Paintable = EditorGUILayout.Toggle("Paintable", obj.Paintable);
                    obj.Coord     = (P3dCoord)EditorGUILayout.EnumPopup("Coord", obj.Coord);
                    obj.Transform = (Transform)EditorGUILayout.ObjectField("Transform", obj.Transform, typeof(Transform), true);

                    if (obj.Transform == null)
                    {
                        obj.Position = EditorGUILayout.Vector3Field("Position", obj.Position);

                        EditorGUI.BeginChangeCheck();
                        var newRot = EditorGUILayout.Vector3Field("Rotation", obj.Rotation.eulerAngles);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            obj.Rotation = Quaternion.Euler(newRot);
                        }

                        obj.Scale = EditorGUILayout.Vector3Field("Scale", obj.Scale);
                    }

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Materials", EditorStyles.boldLabel);
                    if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(20)) == true)
                    {
                        obj.MatIds.Add(-1);
                    }
                    EditorGUILayout.EndHorizontal();

                    for (var j = 0; j < obj.MatIds.Count; j++)
                    {
                        var matId = obj.MatIds[j];
                        var rect  = P3dHelper.Reserve(); rect.xMin += 10;
                        var mat   = scene.GetMat(matId);

                        if (GUI.Button(rect, mat != null ? mat.Name : "", EditorStyles.popup) == true)
                        {
                            var menu = new GenericMenu();

                            for (var k = 0; k < scene.Mats.Count; k++)
                            {
                                var setObj = obj;
                                var setIdx = j;
                                var setMat = scene.Mats[k];

                                menu.AddItem(new GUIContent(setMat.Name), setMat == mat, () => setObj.MatIds[setIdx] = setMat.Id);
                            }

                            var remObj = obj;
                            var remIdx = j;

                            menu.AddSeparator("");
                            menu.AddItem(new GUIContent("Remove"), false, () => remObj.MatIds.RemoveAt(remIdx));

                            menu.DropDown(rect);
                        }
                    }
                }
                else
                {
                    EditorGUILayout.LabelField(obj.Name);
                }
                P3dHelper.EndLabelWidth();
                EditorGUILayout.EndVertical();

                if (Event.current.type == EventType.MouseDown && objRect.Contains(Event.current.mousePosition) == true)
                {
                    currentObj = obj; P3dHelper.ClearControl();
                }
            }
        }
コード例 #16
0
        private void DrawPaintableTexture(P3dPaintableTexture paintableTexture, Material material)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(paintableTexture.Slot.GetTitle(material));
            if (GUILayout.Button("Export", EditorStyles.miniButton, GUILayout.ExpandWidth(false)) == true)
            {
                var path = AssetDatabase.GUIDToAssetPath(paintableTexture.Output);
                var name = paintableTexture.name + "_" + paintableTexture.Slot.Name;
                var dir  = string.IsNullOrEmpty(path) == false?System.IO.Path.GetDirectoryName(path) : "Assets";

                if (string.IsNullOrEmpty(path) == false)
                {
                    name = System.IO.Path.GetFileNameWithoutExtension(path);
                }

                path = EditorUtility.SaveFilePanelInProject("Export Texture", name, "png", "Export Your Texture", dir);

                if (string.IsNullOrEmpty(path) == false)
                {
                    System.IO.File.WriteAllBytes(path, paintableTexture.GetPngData());

                    AssetDatabase.ImportAsset(path);

                    Undo.RecordObject(paintableTexture, "Output Changed");

                    paintableTexture.Output = AssetDatabase.AssetPathToGUID(path);

                    EditorUtility.SetDirty(this);
                }
            }
            EditorGUILayout.EndHorizontal();

            P3dHelper.BeginLabelWidth(100);
            EditorGUI.indentLevel++;
            EditorGUILayout.BeginHorizontal();
            var outputTexture    = paintableTexture.OutputTexture;
            var newOutputTexture = EditorGUILayout.ObjectField(outputTexture, typeof(Texture2D), false);

            EditorGUI.BeginDisabledGroup(outputTexture == null || paintableTexture.Activated == false);
            if (GUILayout.Button("Load", EditorStyles.miniButton, GUILayout.ExpandWidth(false)) == true)
            {
                if (EditorUtility.DisplayDialog("Are you sure?", "This will replace this paintable texture with the currently exported texture state.", "ok") == true)
                {
                    paintableTexture.Replace(outputTexture, Color.white);

                    paintableTexture.Texture = outputTexture;
                }
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndHorizontal();

            if (outputTexture != newOutputTexture)
            {
                Undo.RecordObject(paintableTexture, "Output Changed");

                paintableTexture.Output = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(newOutputTexture));

                EditorUtility.SetDirty(this);
            }

            if (paintableTexture.UndoRedo == P3dPaintableTexture.UndoRedoType.None)
            {
                EditorGUILayout.HelpBox("This texture has no UndoRedo set, so you cannot undo or redo.", MessageType.Warning);
            }

            if (outputTexture == null)
            {
                EditorGUILayout.HelpBox("This texture hasn't been exported yet, so you cannot Export All.", MessageType.Warning);
            }
            EditorGUI.indentLevel--;
            P3dHelper.EndLabelWidth();
        }
コード例 #17
0
        private void UpdateMaterialsPanel()
        {
            for (var i = 0; i < scene.Mats.Count; i++)
            {
                EditorGUILayout.Space();

                var mat     = scene.Mats[i];
                var matRect =
                    EditorGUILayout.BeginVertical(GetSelectableStyle(mat == currentMat, true));
                P3dHelper.BeginLabelWidth(60.0f);
                if (mat == currentMat)
                {
                    EditorGUILayout.BeginHorizontal();
                    P3dHelper.BeginColor(scene.MatNameValid(mat.Name) == false);
                    mat.Name = EditorGUILayout.TextField(mat.Name);
                    P3dHelper.EndColor();
                    if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(20)) == true && EditorUtility.DisplayDialog("Are you sure?", "This will delete the current material from the paint window.", "Delete") == true)
                    {
                        scene.Mats.RemoveAt(i--); P3dHelper.ClearControl();
                    }
                    EditorGUILayout.EndHorizontal();
                    P3dHelper.BeginColor(mat.Material == null);
                    mat.Material = (Material)EditorGUILayout.ObjectField("Material", mat.Material, typeof(Material), true);
                    P3dHelper.EndColor();
                    P3dHelper.BeginColor(mat.Template == null);
                    P3dShaderTemplate_Editor.DrawDropdown("Template", mat.Material, mat);
                    P3dHelper.EndColor();
                    mat.Width  = EditorGUILayout.IntField("Width", mat.Width);
                    mat.Height = EditorGUILayout.IntField("Height", mat.Height);

                    /*
                     *              foreach (var slot in mat.Slots)
                     *              {
                     *                      EditorGUILayout.ObjectField(slot.Texture, typeof(Texture), false);
                     *              }
                     *
                     *              foreach (var layer in mat.MergedLayers.Values)
                     *              {
                     *                      if (layer.Layer != null)
                     *                      {
                     *                      EditorGUILayout.LabelField(layer.Layer.Name );
                     *                      }
                     *                      EditorGUILayout.ObjectField(layer.Under, typeof(Texture), false);
                     *                      EditorGUILayout.ObjectField(layer.Above, typeof(Texture), false);
                     *                      EditorGUILayout.ObjectField(layer.Final, typeof(Texture), false);
                     *              }
                     */
                    if (mat.SizesMatch == false && GUILayout.Button("Resize") == true)
                    {
                        mat.Resize();
                    }
                }
                else
                {
                    EditorGUILayout.LabelField(mat.Name);
                }
                P3dHelper.EndLabelWidth();
                EditorGUILayout.EndVertical();

                if (Event.current.type == EventType.MouseDown && matRect.Contains(Event.current.mousePosition) == true)
                {
                    currentMat = mat; P3dHelper.ClearControl();
                }
            }

            if (GUILayout.Button("Add Material") == true)
            {
                currentMat = scene.AddMat(null, null, settings.DefaultTextureSize); P3dHelper.ClearControl();
            }
        }
コード例 #18
0
        private void DrawPaintTab()
        {
            visitedPaintTab = true;

            if (selectingTool == true)
            {
                DrawTool(); return;
            }

            if (selectingMaterial == true)
            {
                DrawMaterial(); return;
            }

            if (selectingShape == true)
            {
                DrawShape(); return;
            }

            paintScrollPosition = GUILayout.BeginScrollView(paintScrollPosition, GUILayout.ExpandHeight(true));
            DrawTop();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawRadius();
            P3dHelper.EndLabelWidth();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawColor();
            P3dHelper.EndLabelWidth();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawAngle();
            P3dHelper.EndLabelWidth();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawTiling();
            P3dHelper.EndLabelWidth();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawNormal();
            P3dHelper.EndLabelWidth();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawModifiers();
            P3dHelper.EndLabelWidth();
            GUILayout.EndScrollView();

            GUILayout.FlexibleSpace();

            if (Application.isPlaying == false)
            {
                EditorGUILayout.HelpBox("You must enter play mode to begin painting.", MessageType.Warning);
            }
            else
            {
                if (SceneView.sceneViews.Contains(mouseOverWindow) == true)
                {
                    EditorGUILayout.HelpBox("You can only paint in the Game view.", MessageType.Warning);
                }

                if (toolInstance != null)
                {
                    if (GUILayout.Button(new GUIContent("Unload Paint Brush", "If you want to keep this window open but don't want to perform in-editor painting any more, then you can click this.")) == true)
                    {
                        ClearTool();

                        visitedPaintTab = false;
                        currentPage     = PageType.Scene;
                    }
                }
            }

            UpdatePaint();
        }
コード例 #19
0
        private void DrawPaintTab()
        {
            if (selectingTool == true)
            {
                DrawTool(); return;
            }

            if (selectingMaterial == true)
            {
                DrawMaterial(); return;
            }

            if (selectingShape == true)
            {
                DrawShape(); return;
            }

            paintScrollPosition = GUILayout.BeginScrollView(paintScrollPosition, GUILayout.ExpandHeight(true));
            DrawTop();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawRadius();
            P3dHelper.EndLabelWidth();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawColor();
            P3dHelper.EndLabelWidth();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawAngle();
            P3dHelper.EndLabelWidth();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawTiling();
            P3dHelper.EndLabelWidth();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawNormal();
            P3dHelper.EndLabelWidth();

            EditorGUILayout.Separator();

            P3dHelper.BeginLabelWidth(100);
            DrawModifiers();
            P3dHelper.EndLabelWidth();
            GUILayout.EndScrollView();

            GUILayout.FlexibleSpace();

            if (Application.isPlaying == false)
            {
                EditorGUILayout.HelpBox("You must enter play mode to begin painting.", MessageType.Warning);
            }
            else if (SceneView.sceneViews.Contains(mouseOverWindow) == true)
            {
                EditorGUILayout.HelpBox("You can only paint in the Game view.", MessageType.Warning);
            }

            UpdatePaint();
        }