コード例 #1
0
ファイル: SplineMeshEditor.cs プロジェクト: Wanyea/Galaga
        void OnRenameChannel(object index)
        {
            SplineMesh extruder = (SplineMesh)target;

            renameChannel = extruder.GetChannel((int)index);
            Repaint();
        }
コード例 #2
0
ファイル: SplineMeshEditor.cs プロジェクト: Wanyea/Galaga
        void OnDuplicateChannel(object index)
        {
            SplineMesh extruder = (SplineMesh)target;

            SplineMesh.Channel source     = extruder.GetChannel((int)index);
            SplineMesh.Channel newChannel = extruder.AddChannel(source.name);
            source.CopyTo(newChannel);
        }
コード例 #3
0
ファイル: SplineMeshEditor.cs プロジェクト: Wanyea/Galaga
        void MeshRow(SplineMesh.Channel channel, int index)
        {
            SplineMesh.Channel.MeshDefinition definition = channel.GetMesh(index);
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(15);
            if (definition.mesh == null)
            {
                GUILayout.Box("NULL", EditorStyles.helpBox, GUILayout.MinWidth(200));
            }
            else
            {
                GUILayout.Box(definition.mesh.name, EditorStyles.helpBox, GUILayout.MinWidth(200));
            }
            EditorGUILayout.EndHorizontal();
            Rect rect = GUILayoutUtility.GetLastRect();

            if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))
            {
                if (Event.current.button == 0)
                {
                    definitionWindow = EditorWindow.GetWindow <MeshDefinitionWindow>(true);
                    definitionWindow.Init((SplineMesh)target, definition);
                }

                if (Event.current.button == 1)
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Duplicate"), false, OnDuplicateMesh, new MeshLink(index, channel));
                    if (index == 0)
                    {
                        menu.AddDisabledItem(new GUIContent("Move Up"));
                    }
                    else
                    {
                        menu.AddItem(new GUIContent("Move Up"), false, OnMoveMeshUp, new MeshLink(index, channel));
                    }
                    if (index == channel.GetMeshCount() - 1)
                    {
                        menu.AddDisabledItem(new GUIContent("Move Down"));
                    }
                    else
                    {
                        menu.AddItem(new GUIContent("Move Down"), false, OnMoveMeshDown, new MeshLink(index, channel));
                    }
                    menu.AddSeparator("");
                    menu.AddItem(new GUIContent("Delete"), false, OnDeleteMesh, new MeshLink(index, channel));
                    menu.ShowAsContext();
                }
            }
        }
コード例 #4
0
ファイル: SplineMeshEditor.cs プロジェクト: Wanyea/Galaga
 internal MeshLink(int i, SplineMesh.Channel l)
 {
     index   = i;
     channel = l;
 }
コード例 #5
0
ファイル: SplineMeshEditor.cs プロジェクト: Wanyea/Galaga
        bool ChannelPanel(int channelIndex)
        {
            SplineMesh.Channel channel = ((SplineMesh)target).GetChannel(channelIndex);
            bool open = selectedChannel == channelIndex;

            GUILayout.BeginVertical(EditorStyles.helpBox);
            if (renameChannel == channel && Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter))
            {
                renameChannel = null;
                Repaint();
            }
            if (renameChannel == channel)
            {
                channel.name = EditorGUILayout.TextField(channel.name);
            }
            else
            {
                EditorGUILayout.LabelField(channel.name, EditorStyles.boldLabel);
            }
            if (!open)
            {
                GUILayout.EndVertical();
                return(GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition));
            }
            Rect labelRect = GUILayoutUtility.GetLastRect();

            EditorGUI.indentLevel++;
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Mesh Objects", EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal();
            EditorGUIUtility.labelWidth = 100f;
            EditorGUILayout.BeginVertical();
            for (int i = 0; i < channel.GetMeshCount(); i++)
            {
                MeshRow(channel, i);
            }
            Object obj = null;

            obj = EditorGUILayout.ObjectField("Add Mesh", obj, typeof(Object), true);
            if (obj != null)
            {
                if (obj is Mesh)
                {
                    channel.AddMesh((Mesh)obj);
                }
                else
                {
                    Mesh m = GetMeshFromObject(obj);
                    if (m != null)
                    {
                        channel.AddMesh(m);
                    }
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical();
            channel.type = (SplineMesh.Channel.Type)EditorGUILayout.EnumPopup("Type", channel.type);
            if (channel.autoCount)
            {
                EditorGUILayout.TextField("Auto Count: " + channel.count);
            }
            else
            {
                channel.count = EditorGUILayout.IntField("Count", channel.count);
            }
            channel.autoCount   = EditorGUILayout.Toggle("Auto Count", channel.autoCount);
            channel.randomOrder = EditorGUILayout.Toggle("Random Order", channel.randomOrder);
            if (channel.randomOrder)
            {
                channel.randomSeed = EditorGUILayout.IntField("Seed", channel.randomSeed);
            }
            EditorGUILayout.EndVertical();
            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            float clipFrom = (float)channel.clipFrom;
            float clipTo   = (float)channel.clipTo;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.MinMaxSlider(new GUIContent("Clip Range:"), ref clipFrom, ref clipTo, 0f, 1f);
            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.EndHorizontal();
            channel.clipFrom = clipFrom;
            channel.clipTo   = clipTo;
            EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(30));
            channel.clipFrom = EditorGUILayout.FloatField((float)channel.clipFrom);
            channel.clipTo   = EditorGUILayout.FloatField((float)channel.clipTo);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Geometry", EditorStyles.boldLabel);

            if (channel.type != SplineMesh.Channel.Type.Place)
            {
                channel.spacing = EditorGUILayout.Slider("Spacing", (float)channel.spacing, 0f, 1f);
            }

            //Offset
            channel.minOffset = EditorGUILayout.Vector2Field(channel.randomOffset ? "Offset Min" : "Offset", channel.minOffset);
            if (channel.randomOffset)
            {
                channel.maxOffset = EditorGUILayout.Vector2Field("Offset Max", channel.maxOffset);
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUIUtility.labelWidth = 130f;
            channel.randomOffset        = EditorGUILayout.Toggle("Randomize Offset", channel.randomOffset);
            if (channel.randomOffset)
            {
                channel.offsetSeed = EditorGUILayout.IntField("Seed", channel.offsetSeed);
            }
            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            //Rotation
            if (channel.type == SplineMesh.Channel.Type.Extrude)
            {
                Vector3 rot = channel.minRotation;
                rot.z = EditorGUILayout.FloatField(channel.randomRotation ? "Rotation Min" : "Rotation", rot.z);
                channel.minRotation = rot;
                if (channel.randomRotation)
                {
                    rot   = channel.maxRotation;
                    rot.z = EditorGUILayout.FloatField("Rotation Max", rot.z);
                    channel.maxRotation = rot;
                }
            }
            else
            {
                channel.minRotation = EditorGUILayout.Vector3Field(channel.randomRotation ? "Rotation Min" : "Rotation", channel.minRotation);
                if (channel.randomRotation)
                {
                    channel.maxRotation = EditorGUILayout.Vector3Field("Rotation Max", channel.maxRotation);
                }
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUIUtility.labelWidth = 130f;
            channel.randomRotation      = EditorGUILayout.Toggle("Randomize Rotation", channel.randomRotation);
            if (channel.randomRotation)
            {
                channel.rotationSeed = EditorGUILayout.IntField("Seed", channel.rotationSeed);
            }
            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            //Scale
            if (channel.type == SplineMesh.Channel.Type.Extrude)
            {
                float   lastZ = channel.minScale.z;
                Vector3 scale = channel.minScale;
                scale            = EditorGUILayout.Vector2Field(channel.randomScale ? "Scale Min" : "Scale", scale);
                scale           += Vector3.forward * lastZ;
                channel.minScale = scale;
                if (channel.randomScale)
                {
                    lastZ            = channel.maxScale.z;
                    scale            = channel.maxScale;
                    scale            = EditorGUILayout.Vector2Field("Scale Max", scale);
                    scale           += Vector3.forward * lastZ;
                    channel.maxScale = scale;
                }
            }
            else
            {
                channel.minScale = EditorGUILayout.Vector3Field(channel.randomScale ? "Scale Min" : "Scale", channel.minScale);
                if (channel.randomScale)
                {
                    channel.maxScale = EditorGUILayout.Vector3Field("Scale Max", channel.maxScale);
                }
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUIUtility.labelWidth = 130f;
            channel.randomScale         = EditorGUILayout.Toggle("Randomize Scale", channel.randomScale);
            if (channel.randomScale)
            {
                channel.scaleSeed = EditorGUILayout.IntField("Seed", channel.scaleSeed);
            }
            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.EndHorizontal();
            if (channel.randomScale)
            {
                EditorGUI.indentLevel++;
                EditorGUIUtility.labelWidth = 120f;
                channel.uniformRandomScale  = EditorGUILayout.Toggle("Uniform", channel.uniformRandomScale);
                EditorGUIUtility.labelWidth = 0f;
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("UV Coordinates", EditorStyles.boldLabel);
            channel.uvOffset = EditorGUILayout.Vector2Field("UV Offset", channel.uvOffset);
            channel.uvScale  = EditorGUILayout.Vector2Field("UV Scale", channel.uvScale);

            //Override

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Override", EditorStyles.boldLabel);
            channel.overrideNormal = EditorGUILayout.Toggle("Normal", channel.overrideNormal);
            if (channel.overrideNormal)
            {
                channel.customNormal = EditorGUILayout.Vector3Field("Normal", channel.customNormal);
            }

            if (channel.type == SplineMesh.Channel.Type.Extrude)
            {
                channel.overrideUVs = (SplineMesh.Channel.UVOverride)EditorGUILayout.EnumPopup("UVs", channel.overrideUVs);
                if (channel.overrideUVs != SplineMesh.Channel.UVOverride.None)
                {
                }
            }

            channel.overrideMaterialID = EditorGUILayout.Toggle("Material IDs", channel.overrideMaterialID);
            if (channel.overrideMaterialID)
            {
                channel.targetMaterialID = EditorGUILayout.IntField("Target ID", channel.targetMaterialID);
            }


            if (scaleModifierEditor != null)
            {
                EditorGUILayout.LabelField("Scale Regions", EditorStyles.boldLabel);
                scaleModifierEditor.DrawInspector();
            }
            EditorGUI.indentLevel--;
            GUILayout.EndVertical();
            return(labelRect.Contains(Event.current.mousePosition));
        }