コード例 #1
0
    public void OnGUI()
    {
        skin = (SkinnedMeshRenderer)EditorGUILayout.ObjectField("Skin", skin, typeof(SkinnedMeshRenderer), true);

        if (skin != null && skin.bones.Length > 0)
        {
            GUI.color = (isPainting) ? Color.green : Color.white;

            if (GUILayout.Button("Paint"))
            {
                isPainting = !isPainting;
                if (isPainting)
                {
                    Selection.objects = new GameObject[] { skin.gameObject };
                }
                SceneView.currentDrawingSceneView.Repaint();
            }

            GUI.color = Color.white;

            brushSize = EditorGUILayout.FloatField("Brush size", brushSize * 2) / 2;
            weight    = Mathf.Clamp(EditorGUILayout.FloatField("Weight", weight), 0, 1);
            mode      = (PaintingMode)EditorGUILayout.EnumPopup("Mode", mode);

            string[] bones = skin.bones.Select(b => b.gameObject.name).ToArray();
            boneIndex         = EditorGUILayout.Popup("Bone", boneIndex, bones);
            colorTransparency = Mathf.Clamp(EditorGUILayout.FloatField("Color Transparency", colorTransparency), 0, 1);
        }
        else
        {
            EditorGUILayout.HelpBox("SkinnedMeshRenderer not assigned to any bones, Recalculate Bone Weights.", MessageType.Error);
            SceneView.currentDrawingSceneView.Repaint();
        }
    }
コード例 #2
0
    public void OnGUI()
    {
        skin = (SkinnedMeshRenderer)EditorGUILayout.ObjectField("Skin", skin, typeof(SkinnedMeshRenderer), true);

        if (skin != null)
        {
            GUI.color = (isPainting) ? Color.green : Color.white;

            if (GUILayout.Button("Paint"))
            {
                isPainting = !isPainting;
                if (isPainting)
                {
                    Selection.objects = new GameObject[] { skin.gameObject };
                }
                SceneView.currentDrawingSceneView.Repaint();
            }

            GUI.color = Color.white;

            brushSize = EditorGUILayout.FloatField("Brush size", brushSize * 2) / 2;
            weight    = Mathf.Clamp(EditorGUILayout.FloatField("Weight", weight), 0, 1);
            mode      = (PaintingMode)EditorGUILayout.EnumPopup("Mode", mode);

            string[] bones = skin.bones.Select(b => b.gameObject.name).ToArray();
            bone = EditorGUILayout.Popup("Bone", bone, bones);
        }
    }
コード例 #3
0
    void DisplayPaletteMenu(PaintingMode mode)
    {
        paintingMode = mode;
        GenericMenu menu = new GenericMenu();

        foreach (PaletteEntry entry in structure.palette)
        {
            if (!entry.isValid)
            {
                continue;
            }
            string text;
            if (!entry.isOreDict)
            {
                text = string.Format("[{0}] {1}:{2}", entry.identifier, entry.mod, entry.name);
            }
            else
            {
                text = string.Format("[{0}] {1}", entry.identifier, entry.name);
            }
            bool isSelected = paintingMode == PaintingMode.SelectedOnly ? entry.identifier == structure.validFullBlocks[currentBlock].paletteValue : false;
            menu.AddItem(new GUIContent(text), isSelected, OnPaletteSelected, entry);
        }
        menu.ShowAsContext();
    }
コード例 #4
0
    public void OnGUI() {
        skin = (SkinnedMeshRenderer)EditorGUILayout.ObjectField("Skin", skin, typeof(SkinnedMeshRenderer), true);

        if (skin != null) {
            GUI.color = (isPainting) ? Color.green : Color.white;

            if (GUILayout.Button("Paint")) {
                isPainting = !isPainting;
                if (isPainting) {
                    Selection.objects = new GameObject[] { skin.gameObject };
                }
                SceneView.currentDrawingSceneView.Repaint();
            }

            GUI.color = Color.white;

            brushSize = EditorGUILayout.FloatField("Brush size", brushSize * 2) / 2;
            weight = Mathf.Clamp(EditorGUILayout.FloatField("Weight", weight), 0, 1);
            mode = (PaintingMode)EditorGUILayout.EnumPopup("Mode", mode);

            string[] bones = skin.bones.Select(b => b.gameObject.name).ToArray();
            bone = EditorGUILayout.Popup("Bone", bone, bones);

        }
    }
コード例 #5
0
        /// <summary>
        /// 切换模式
        /// </summary>
        /// <param name="mode"></param>
        public void SwitchPaintingMode(PaintingMode mode)
        {
            // 先设置背景色
            AdInkCanvas.Background = new SolidColorBrush(Color.FromArgb(1, 0, 0, 0));
            switch (mode)
            {
            case PaintingMode.Pen:
                this.AdInkCanvas.EditingMode = InkCanvasEditingMode.Ink;
                break;

            case PaintingMode.Eraser:
                this.AdInkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
                break;

            case PaintingMode.Non:
                this.AdInkCanvas.EditingMode = InkCanvasEditingMode.None;
                break;

            case PaintingMode.DeskTop:
                this.AdInkCanvas.EditingMode = InkCanvasEditingMode.None;
                // 设置画板背景色为透明
                AdInkCanvas.Background = Brushes.Transparent;
                break;

            case PaintingMode.Select:
                AdInkCanvas.EditingMode = InkCanvasEditingMode.Select;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
            }
        }
コード例 #6
0
    public void OnGUI() {
        skin = (SkinnedMeshRenderer)EditorGUILayout.ObjectField("Skin", skin, typeof(SkinnedMeshRenderer), true);

        if (skin != null && skin.bones.Length > 0) {
            GUI.color = (isPainting) ? Color.green : Color.white;

            if (GUILayout.Button("Paint")) {
                isPainting = !isPainting;
                if (isPainting) {
                    Selection.objects = new GameObject[] { skin.gameObject };
                }
                SceneView.currentDrawingSceneView.Repaint();
            }

            GUI.color = Color.white;

            brushSize = EditorGUILayout.FloatField("Brush size", brushSize * 2) / 2;
            weight = Mathf.Clamp(EditorGUILayout.FloatField("Weight", weight), 0, 1);
            mode = (PaintingMode)EditorGUILayout.EnumPopup("Mode", mode);

            string[] bones = skin.bones.Select(b => b.gameObject.name).ToArray();
			boneIndex = EditorGUILayout.Popup("Bone", boneIndex, bones);
            colorTransparency = Mathf.Clamp(EditorGUILayout.FloatField("Color Transparency", colorTransparency), 0, 1);

        } else {
			EditorGUILayout.HelpBox("SkinnedMeshRenderer not assigned to any bones, Recalculate Bone Weights.", MessageType.Error);
			if (SceneView.currentDrawingSceneView != null)
				SceneView.currentDrawingSceneView.Repaint();
		}
    }
コード例 #7
0
        public List <int>      AffectedChildChunks; //0 means main layer

        public PaintingParameters(Shape shape, Vector2Int position, Color color, PaintingMode paintingMode = PaintingMode.REPLACE_COLOR, DestructionMode destructionMode = DestructionMode.NONE, List <int> affectedChildChunks = null)
        {
            Shape           = shape;
            Position        = position;
            Color           = color;
            PaintingMode    = paintingMode;
            DestructionMode = destructionMode;
            if (affectedChildChunks == null)
            {
                AffectedChildChunks = new List <int>()
                {
                    0
                }
            }
            ;
            else
            {
                AffectedChildChunks = affectedChildChunks;
            }
        }
コード例 #8
0
ファイル: Weightpainter.cs プロジェクト: yazici/Boner2D
        public void OnGUI()
        {
            EditorGUI.BeginChangeCheck();

            skin = (SkinnedMeshRenderer)EditorGUILayout.ObjectField("Skin", skin, typeof(SkinnedMeshRenderer), true);

            if (EditorGUI.EndChangeCheck() || skin != null && bones == null)
            {
                if (skin != null)
                {
                    bones = new Bone[skin.bones.Length];

                    for (int i = 0; i < skin.bones.Length; i++)
                    {
                        bones[i] = skin.bones[i].GetComponent <Bone>();
                    }
                }
                else
                {
                    if (bones != null)
                    {
                        bones = null;
                    }
                }
            }

            if (skin != null && skin.bones.Length > 0)
            {
                GUI.color = (isPainting) ? Color.green : Color.white;

                if (GUILayout.Button("Paint"))
                {
                    isPainting = !isPainting;

                    if (isPainting)
                    {
                        Selection.objects = new GameObject[] { skin.gameObject };
                    }
                    else
                    {
                        // Reset the mesh
                        mesh = null;

                        // Save the asset when finished painting
                        if (wasDrawing && !isPainting)
                        {
                            EditorUtility.SetDirty(skin.gameObject);

                            if (PrefabUtility.GetPrefabType(skin.gameObject) != PrefabType.None)
                            {
                                AssetDatabase.SaveAssets();
                            }

                            wasDrawing      = false;
                            recalculateMesh = true;
                        }
                    }

                    if (SceneView.currentDrawingSceneView != null)
                    {
                        SceneView.currentDrawingSceneView.Repaint();
                    }
                }

                GUI.color = Color.white;

                brushSize = EditorGUILayout.FloatField("Brush size", brushSize * 2) / 2;

                weight = Mathf.Clamp(EditorGUILayout.FloatField("Weight", weight), 0, 1);

                mode = (PaintingMode)EditorGUILayout.EnumPopup("Mode", mode);

                if (bones != null)
                {
                    boneNames = bones.Select(b => b.gameObject.name).ToArray();

                    boneIndex = EditorGUILayout.Popup("Bone", boneIndex, boneNames);
                }

                colorTransparency = Mathf.Clamp(EditorGUILayout.FloatField("Color Transparency", colorTransparency), 0, 1);
            }
            else
            {
                EditorGUILayout.HelpBox("SkinnedMeshRenderer not assigned to any bones, Recalculate Bone Weights.", MessageType.Error);

                if (SceneView.currentDrawingSceneView != null)
                {
                    SceneView.currentDrawingSceneView.Repaint();
                }
            }
        }
コード例 #9
0
 private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (mode == (PaintingMode) toolStripComboBox1.SelectedItem) return;
     mode = (PaintingMode) toolStripComboBox1.SelectedItem;
     InitPainting();
 }
コード例 #10
0
        private void InitModes()
        {
            mode = PaintingMode.ColorsWithProbability;

            toolStripComboBox1.Items.AddRange(Enum.GetValues(typeof (PaintingMode)).Cast<object>().ToArray());
            toolStripComboBox1.SelectedItem = mode;
        }