private TreeViewItem AddAnimatableObjectToHierarchy(EditorCurveBinding[] curveBindings, TreeViewItem parentNode, string path)
        {
            TreeViewItem node = new AddCurvesPopupObjectNode(parentNode, path, GetClassName(curveBindings[0]));

            node.icon = GetIcon(curveBindings[0]);

            List <TreeViewItem>       childNodes             = new List <TreeViewItem>();
            List <EditorCurveBinding> singlePropertyBindings = new List <EditorCurveBinding>();

            for (int i = 0; i < curveBindings.Length; i++)
            {
                EditorCurveBinding curveBinding = curveBindings[i];

                singlePropertyBindings.Add(curveBinding);

                // We expect curveBindings to come sorted by propertyname
                if (i == curveBindings.Length - 1 || AnimationWindowUtility.GetPropertyGroupName(curveBindings[i + 1].propertyName) != AnimationWindowUtility.GetPropertyGroupName(curveBinding.propertyName))
                {
                    TreeViewItem newNode = CreateNode(singlePropertyBindings.ToArray(), node);
                    if (newNode != null)
                    {
                        childNodes.Add(newNode);
                    }
                    singlePropertyBindings.Clear();
                }
            }

            childNodes.Sort();

            TreeViewUtility.SetChildParentReferences(childNodes, node);
            return(node);
        }
        private TreeViewItem AddAnimatableObjectToHierarchy(EditorCurveBinding[] curveBindings, TreeViewItem parentNode, string path)
        {
            TreeViewItem treeViewItem = new AddCurvesPopupObjectNode(parentNode, path, AddCurvesPopupHierarchyDataSource.GetClassName(curveBindings[0]));

            treeViewItem.icon = AddCurvesPopupHierarchyDataSource.GetIcon(curveBindings[0]);
            List <TreeViewItem>       list  = new List <TreeViewItem>();
            List <EditorCurveBinding> list2 = new List <EditorCurveBinding>();

            for (int i = 0; i < curveBindings.Length; i++)
            {
                EditorCurveBinding item = curveBindings[i];
                list2.Add(item);
                if (i == curveBindings.Length - 1 || AnimationWindowUtility.GetPropertyGroupName(curveBindings[i + 1].propertyName) != AnimationWindowUtility.GetPropertyGroupName(item.propertyName))
                {
                    TreeViewItem treeViewItem2 = this.CreateNode(list2.ToArray(), treeViewItem);
                    if (treeViewItem2 != null)
                    {
                        list.Add(treeViewItem2);
                    }
                    list2.Clear();
                }
            }
            list.Sort();
            TreeViewUtility.SetChildParentReferences(list, treeViewItem);
            return(treeViewItem);
        }
        private TreeViewItem AddAnimatableObjectToHierarchy(GameObject root, EditorCurveBinding[] curveBindings, TreeViewItem parentNode, string path)
        {
            TreeViewItem item = new AddCurvesPopupObjectNode(parentNode, path, GetClassName(root, curveBindings[0]))
            {
                icon = AssetPreview.GetMiniThumbnail(AnimationUtility.GetAnimatedObject(root, curveBindings[0]))
            };
            List <TreeViewItem>       visibleItems = new List <TreeViewItem>();
            List <EditorCurveBinding> list2        = new List <EditorCurveBinding>();

            for (int i = 0; i < curveBindings.Length; i++)
            {
                EditorCurveBinding binding = curveBindings[i];
                list2.Add(binding);
                if ((i == (curveBindings.Length - 1)) || (AnimationWindowUtility.GetPropertyGroupName(curveBindings[i + 1].propertyName) != AnimationWindowUtility.GetPropertyGroupName(binding.propertyName)))
                {
                    TreeViewItem item2 = this.CreateNode(list2.ToArray(), item);
                    if (item2 != null)
                    {
                        visibleItems.Add(item2);
                    }
                    list2.Clear();
                }
            }
            visibleItems.Sort();
            TreeViewUtility.SetChildParentReferences(visibleItems, item);
            return(item);
        }
 private TreeViewItem AddAnimatableObjectToHierarchy(GameObject root, EditorCurveBinding[] curveBindings, TreeViewItem parentNode, string path)
 {
     TreeViewItem item = new AddCurvesPopupObjectNode(parentNode, path, GetClassName(root, curveBindings[0])) {
         icon = AssetPreview.GetMiniThumbnail(AnimationUtility.GetAnimatedObject(root, curveBindings[0]))
     };
     List<TreeViewItem> visibleItems = new List<TreeViewItem>();
     List<EditorCurveBinding> list2 = new List<EditorCurveBinding>();
     for (int i = 0; i < curveBindings.Length; i++)
     {
         EditorCurveBinding binding = curveBindings[i];
         list2.Add(binding);
         if ((i == (curveBindings.Length - 1)) || (AnimationWindowUtility.GetPropertyGroupName(curveBindings[i + 1].propertyName) != AnimationWindowUtility.GetPropertyGroupName(binding.propertyName)))
         {
             TreeViewItem item2 = this.CreateNode(list2.ToArray(), item);
             if (item2 != null)
             {
                 visibleItems.Add(item2);
             }
             list2.Clear();
         }
     }
     visibleItems.Sort();
     TreeViewUtility.SetChildParentReferences(visibleItems, item);
     return item;
 }
Exemplo n.º 5
0
        private TreeViewItem AddAnimatableObjectToHierarchy(EditorCurveBinding[] curveBindings, TreeViewItem parentNode, string path)
        {
            TreeViewItem node = new AddCurvesPopupObjectNode(parentNode, path, GetClassName(curveBindings[0]));

            node.icon = GetIcon(curveBindings[0]);

            List <TreeViewItem>       childNodes             = new List <TreeViewItem>();
            List <EditorCurveBinding> singlePropertyBindings = new List <EditorCurveBinding>();
            SerializedObject          so = null;

            for (int i = 0; i < curveBindings.Length; i++)
            {
                EditorCurveBinding curveBinding = curveBindings[i];
                if (curveBinding.isSerializeReferenceCurve)
                {
                    var animatedObject = AnimationUtility.GetAnimatedObject(AddCurvesPopup.s_State.activeRootGameObject, curveBinding);
                    if (animatedObject != null && (so == null || so.targetObject != animatedObject))
                    {
                        so = new SerializedObject(animatedObject);
                    }
                }

                singlePropertyBindings.Add(curveBinding);

                // We expect curveBindings to come sorted by propertyname
                if (i == curveBindings.Length - 1 || AnimationWindowUtility.GetPropertyGroupName(curveBindings[i + 1].propertyName) != AnimationWindowUtility.GetPropertyGroupName(curveBinding.propertyName))
                {
                    TreeViewItem newNode = CreateNode(singlePropertyBindings.ToArray(), node, so);
                    if (newNode != null)
                    {
                        childNodes.Add(newNode);
                    }
                    singlePropertyBindings.Clear();
                }
            }

            childNodes.Sort();

            TreeViewUtility.SetChildParentReferences(childNodes, node);
            return(node);
        }
        private TreeViewItem AddScriptableObjectToHierarchy(ScriptableObject scriptableObject, AnimationClip clip, TreeViewItem parent)
        {
            EditorCurveBinding[] animatableBindings = AnimationUtility.GetAnimatableBindings(scriptableObject);
            EditorCurveBinding[] array = (from c in animatableBindings
                                          where !AnimationWindowUtility.IsCurveCreated(clip, c)
                                          select c).ToArray <EditorCurveBinding>();
            TreeViewItem treeViewItem;

            if (array.Length > 0)
            {
                treeViewItem = this.AddAnimatableObjectToHierarchy(array, parent, "");
            }
            else
            {
                treeViewItem = new AddCurvesPopupObjectNode(parent, "", scriptableObject.name);
            }
            if (this.m_RootItem == null)
            {
                this.m_RootItem = treeViewItem;
            }
            return(treeViewItem);
        }
        private TreeViewItem AddScriptableObjectToHierarchy(ScriptableObject scriptableObject, AnimationClip clip, TreeViewItem parent)
        {
            EditorCurveBinding[] allCurveBindings  = AnimationUtility.GetAnimatableBindings(scriptableObject);
            EditorCurveBinding[] availableBindings = allCurveBindings.Where(c => !AnimationWindowUtility.IsCurveCreated(clip, c)).ToArray();

            TreeViewItem node = null;

            if (availableBindings.Length > 0)
            {
                node = AddAnimatableObjectToHierarchy(availableBindings, parent, "");
            }
            else
            {
                node = new AddCurvesPopupObjectNode(parent, "", scriptableObject.name);
            }

            if (m_RootItem == null)
            {
                m_RootItem = node;
            }

            return(node);
        }
		private TreeViewItem AddAnimatableObjectToHierarchy(GameObject root, EditorCurveBinding[] curveBindings, TreeViewItem parentNode, string path)
		{
			TreeViewItem treeViewItem = new AddCurvesPopupObjectNode(parentNode, path, AddCurvesPopupHierarchyDataSource.GetClassName(root, curveBindings[0]));
			treeViewItem.icon = AssetPreview.GetMiniThumbnail(AnimationUtility.GetAnimatedObject(root, curveBindings[0]));
			List<TreeViewItem> list = new List<TreeViewItem>();
			List<EditorCurveBinding> list2 = new List<EditorCurveBinding>();
			for (int i = 0; i < curveBindings.Length; i++)
			{
				EditorCurveBinding item = curveBindings[i];
				list2.Add(item);
				if (i == curveBindings.Length - 1 || AnimationWindowUtility.GetPropertyGroupName(curveBindings[i + 1].propertyName) != AnimationWindowUtility.GetPropertyGroupName(item.propertyName))
				{
					TreeViewItem treeViewItem2 = this.CreateNode(list2.ToArray(), treeViewItem);
					if (treeViewItem2 != null)
					{
						list.Add(treeViewItem2);
					}
					list2.Clear();
				}
			}
			list.Sort();
			TreeViewUtility.SetChildParentReferences(list, treeViewItem);
			return treeViewItem;
		}