Browse Source

Animation field selector window now also shows selectable properties for morph channel frame and weight

BearishSun 9 years ago
parent
commit
d25425bf34

+ 48 - 0
Source/MBansheeEditor/Windows/Animation/GUIFieldSelector.cs

@@ -196,6 +196,54 @@ namespace BansheeEditor
                 }
                 }
             }
             }
 
 
+            // Handle special fields
+            if (serializableObject.Type == typeof(Animation))
+            {
+                Animation anim = serializableObject.Object as Animation;
+                MorphShapes morphShapes = anim?.SceneObject.GetComponent<Renderable>()?.Mesh?.MorphShapes;
+
+                if (morphShapes != null)
+                {
+                    string propertyPath = parent.path + "/MorphShapes";
+
+                    Action<Element, bool> toggleCallback =
+                        (toggleParent, expand) =>
+                        {
+                            toggleParent.childLayout.Clear();
+                            toggleParent.children = null;
+
+                            toggleParent.indentLayout.Active = expand;
+
+                            if (expand)
+                            {
+                                List<Element> childElements = new List<Element>();
+                                MorphChannel[] channels = morphShapes.Channels;
+                                for (int i = 0; i < channels.Length; i++)
+                                {
+                                    string channelName = channels[i].Name;
+
+                                    string framePropertyPath = parent.path + "/MorphShapes/Frames/" + channelName;
+                                    string weightPropertyPath = parent.path + "/MorphShapes/Weight/" + channelName;
+
+                                    elements.Add(AddFieldRow(toggleParent.childLayout, channelName + " (Frames)", 
+                                        toggleParent.so, toggleParent.comp, framePropertyPath, 
+                                        SerializableProperty.FieldType.Float));
+
+                                    elements.Add(AddFieldRow(toggleParent.childLayout, channelName + " (Weight)",
+                                        toggleParent.so, toggleParent.comp, weightPropertyPath,
+                                        SerializableProperty.FieldType.Float));
+                                }
+
+                                toggleParent.children = childElements.ToArray();
+                            }
+                        };
+
+                    
+                    elements.Add(AddFoldoutRow(parent.childLayout, null, "MorphShapes", parent.so, parent.comp,
+                        propertyPath, toggleCallback));
+                }
+            }
+
             parent.children = elements.ToArray();
             parent.children = elements.ToArray();
         }
         }
 
 

+ 14 - 0
Source/MBansheeEngine/Serialization/SerializableObject.cs

@@ -20,6 +20,17 @@ namespace BansheeEngine
         internal SerializableProperty parentProperty;
         internal SerializableProperty parentProperty;
         internal object parentObject;
         internal object parentObject;
         private SerializableField[] _fields;
         private SerializableField[] _fields;
+        private Type type;
+
+        /// <summary>
+        /// Type of the underlying object.
+        /// </summary>
+        public Type Type { get { return type; } }
+
+        /// <summary>
+        /// Underlying object instance, if any.
+        /// </summary>
+        public object Object { get { return parentObject; } }
 
 
         /// <summary>
         /// <summary>
         /// Creates a new serializable object for the specified object type.
         /// Creates a new serializable object for the specified object type.
@@ -32,6 +43,7 @@ namespace BansheeEngine
 
 
             this.parentProperty = parentProperty;
             this.parentProperty = parentProperty;
             this.parentObject = null;
             this.parentObject = null;
+            this.type = objectType;
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -45,6 +57,7 @@ namespace BansheeEngine
 
 
             this.parentProperty = null;
             this.parentProperty = null;
             this.parentObject = parentObject;
             this.parentObject = parentObject;
+            this.type = objectType;
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -57,6 +70,7 @@ namespace BansheeEngine
 
 
             this.parentProperty = null;
             this.parentProperty = null;
             this.parentObject = parentObject;
             this.parentObject = parentObject;
+            this.type = parentObject.GetType();
         }
         }
 
 
         /// <summary>
         /// <summary>