Esempio n. 1
0
        private void OnShapeListGUI(GUISkin skin)
        {
            if (!GUI.Foldout(EditorData.Instance.GetData(RigidBody, "Shapes"), GUI.MakeLabel("Shapes", true), skin))
            {
                return;
            }

            Shape[] shapes = RigidBody.GetComponentsInChildren <Shape>();
            if (shapes.Length == 0)
            {
                using (new GUI.Indent(12))
                    GUILayout.Label(GUI.MakeLabel("Empty", true), skin.label);
                return;
            }

            using (new GUI.Indent(12)) {
                foreach (var shape in shapes)
                {
                    GUI.Separator();
                    if (!GUI.Foldout(EditorData.Instance.GetData(RigidBody,
                                                                 shape.GetInstanceID().ToString()),
                                     GUI.MakeLabel("[" + GUI.AddColorTag(shape.GetType().Name, Color.Lerp(Color.green, Color.black, 0.4f)) + "] " + shape.name),
                                     skin))
                    {
                        continue;
                    }

                    GUI.Separator();
                    using (new GUI.Indent(12)) {
                        Undo.RecordObjects(shape.GetUndoCollection(), "Shape");

                        shape.enabled = GUI.Toggle(GUI.MakeLabel("Enable"), shape.enabled, skin.button, skin.label);
                        if (shape is AgXUnity.Collide.Mesh)
                        {
                            GUI.Separator();

                            var newMeshSource = GUI.ShapeMeshSourceGUI((shape as AgXUnity.Collide.Mesh).SourceObjects.FirstOrDefault(), skin);
                            if (newMeshSource != null)
                            {
                                (shape as AgXUnity.Collide.Mesh).SetSourceObject(newMeshSource);
                            }
                        }
                        GUI.Separator();
                        BaseEditor <Shape> .Update(shape, shape, skin);
                    }
                }
            }
        }
Esempio n. 2
0
        public override void OnPreTargetMembersGUI(GUISkin skin)
        {
            base.OnPreTargetMembersGUI(skin);

            var sourceObjects = Mesh.SourceObjects;
            var singleSource  = sourceObjects.FirstOrDefault();

            Undo.RecordObjects(Mesh.GetUndoCollection(), "Mesh source");

            var newSingleSource = GUI.ShapeMeshSourceGUI(singleSource, skin);

            if (newSingleSource != null)
            {
                Mesh.SetSourceObject(newSingleSource);
            }

            GUI.Separator();
        }