private void addCurve(object userData) { AddCurveContext arg = userData as AddCurveContext; if (arg != null) { Type t = null; PropertyInfo property = arg.memberInfo as PropertyInfo; FieldInfo field = arg.memberInfo as FieldInfo; bool isProperty = false; if (property != null) { t = property.PropertyType; isProperty = true; } else if (field != null) { t = field.FieldType; isProperty = false; } Undo.RecordObject(arg.clipCurve, "Added Curve"); arg.clipCurve.AddClipCurveData(arg.component, arg.memberInfo.Name, isProperty, t); EditorUtility.SetDirty(arg.clipCurve); } }
protected override void showContextMenu(Behaviour behaviour) { CinemaActorClipCurve clipCurve = behaviour as CinemaActorClipCurve; if (clipCurve == null) { return; } List <KeyValuePair <string, string> > currentCurves = new List <KeyValuePair <string, string> >(); { var __list1 = clipCurve.CurveData; var __listCount1 = __list1.Count; for (int __i1 = 0; __i1 < __listCount1; ++__i1) { var data = (MemberClipCurveData)__list1[__i1]; { KeyValuePair <string, string> curveStrings = new KeyValuePair <string, string>(data.Type, data.PropertyName); currentCurves.Add(curveStrings); } } } GenericMenu createMenu = new GenericMenu(); if (clipCurve.Actor != null) { Component[] components = DirectorHelper.getValidComponents(clipCurve.Actor.gameObject); for (int i = 0; i < components.Length; i++) { Component component = components[i]; MemberInfo[] members = DirectorHelper.getValidMembers(component); for (int j = 0; j < members.Length; j++) { AddCurveContext context = new AddCurveContext(); context.clipCurve = clipCurve; context.component = component; context.memberInfo = members[j]; if (!currentCurves.Contains(new KeyValuePair <string, string>(component.GetType().Name, members[j].Name))) { createMenu.AddItem(new GUIContent(string.Format("Add Curve/{0}/{1}", component.GetType().Name, DirectorHelper.GetUserFriendlyName(component, members[j]))), false, addCurve, context); } } } createMenu.AddSeparator(string.Empty); } createMenu.AddItem(new GUIContent("Copy"), false, copyItem, behaviour); createMenu.AddSeparator(string.Empty); createMenu.AddItem(new GUIContent("Clear"), false, deleteItem, clipCurve); createMenu.ShowAsContext(); }
protected override void showContextMenu(Behaviour behaviour) { CinemaActorClipCurve clipCurve = behaviour as CinemaActorClipCurve; if (clipCurve == null) return; List<KeyValuePair<string, string>> currentCurves = new List<KeyValuePair<string, string>>(); foreach (MemberClipCurveData data in clipCurve.CurveData) { KeyValuePair<string, string> curveStrings = new KeyValuePair<string, string>(data.Type, data.PropertyName); currentCurves.Add(curveStrings); } GenericMenu createMenu = new GenericMenu(); if (clipCurve.Actor != null) { Component[] components = DirectorHelper.getValidComponents(clipCurve.Actor.gameObject); for (int i = 0; i < components.Length; i++) { Component component = components[i]; MemberInfo[] members = DirectorHelper.getValidMembers(component); for (int j = 0; j < members.Length; j++) { AddCurveContext context = new AddCurveContext(); context.clipCurve = clipCurve; context.component = component; context.memberInfo = members[j]; if (!currentCurves.Contains(new KeyValuePair<string, string>(component.GetType().Name, members[j].Name))) { createMenu.AddItem(new GUIContent(string.Format("Add Curve/{0}/{1}", component.GetType().Name, DirectorHelper.GetUserFriendlyName(component, members[j]))), false, addCurve, context); } } } createMenu.AddSeparator(string.Empty); } createMenu.AddItem(new GUIContent("Copy"), false, copyItem, behaviour); createMenu.AddSeparator(string.Empty); createMenu.AddItem(new GUIContent("Clear"), false, deleteItem, clipCurve); createMenu.ShowAsContext(); }