Ejemplo n.º 1
0
        public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused)
        {
            bool propertyPathMismatchWithHumanAvatar        = false;
            AddCurvesPopupGameObjectNode addCurvesPopupNode = node as AddCurvesPopupGameObjectNode;

            if (addCurvesPopupNode != null)
            {
                propertyPathMismatchWithHumanAvatar = addCurvesPopupNode.propertyPathMismatchWithHumanAvatar;
            }

            using (new EditorGUI.DisabledScope(propertyPathMismatchWithHumanAvatar))
            {
                base.OnRowGUI(rowRect, node, row, selected, focused);
                DoAddCurveButton(rowRect, node);
                HandleContextMenu(rowRect, node);
            }

            if (propertyPathMismatchWithHumanAvatar)
            {
                Rect iconRect = new Rect(rowRect.width - plusButtonWidth, rowRect.yMin, plusButtonWidth, buttonStyle.fixedHeight);
                GUI.Label(iconRect, new GUIContent(warningIcon, "The Avatar definition does not match the property path. Please author using a hierarchy the Avatar was built with."), warningIconStyle);
            }
        }
        private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, GameObject rootGameObject, AnimationClip animationClip, TreeViewItem parent)
        {
            string              path       = AnimationUtility.CalculateTransformPath(gameObject.transform, rootGameObject.transform);
            TreeViewItem        node       = new AddCurvesPopupGameObjectNode(gameObject, parent, gameObject.name);
            List <TreeViewItem> childNodes = new List <TreeViewItem>();

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

            // Iterate over all animatable objects
            EditorCurveBinding[]      allCurveBindings     = AnimationUtility.GetAnimatableBindings(gameObject, rootGameObject);
            List <EditorCurveBinding> singleObjectBindings = new List <EditorCurveBinding>();

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

                singleObjectBindings.Add(curveBinding);

                // Don't create group for GameObject.m_IsActive. It looks messy
                if (curveBinding.propertyName == "m_IsActive")
                {
                    // Don't show for the root go
                    if (curveBinding.path != "")
                    {
                        TreeViewItem newNode = CreateNode(singleObjectBindings.ToArray(), node);
                        if (newNode != null)
                        {
                            childNodes.Add(newNode);
                        }
                        singleObjectBindings.Clear();
                    }
                    else
                    {
                        singleObjectBindings.Clear();
                    }
                }
                else
                {
                    // We expect allCurveBindings to come sorted by type

                    bool isLastItemOverall     = (i == allCurveBindings.Length - 1);
                    bool isLastItemOnThisGroup = false;

                    if (!isLastItemOverall)
                    {
                        isLastItemOnThisGroup = (allCurveBindings[i + 1].type != curveBinding.type);
                    }

                    // Let's not add those that already have a existing curve.
                    if (AnimationWindowUtility.IsCurveCreated(animationClip, curveBinding))
                    {
                        singleObjectBindings.Remove(curveBinding);
                    }

                    // Remove animator enabled property which shouldn't be animated.
                    if (curveBinding.type == typeof(Animator) && curveBinding.propertyName == "m_Enabled")
                    {
                        singleObjectBindings.Remove(curveBinding);
                    }

                    if ((isLastItemOverall || isLastItemOnThisGroup) && singleObjectBindings.Count > 0)
                    {
                        childNodes.Add(AddAnimatableObjectToHierarchy(singleObjectBindings.ToArray(), node, path));
                        singleObjectBindings.Clear();
                    }
                }
            }

            if (showEntireHierarchy)
            {
                // Iterate over all child GOs
                for (int i = 0; i < gameObject.transform.childCount; i++)
                {
                    Transform    childTransform = gameObject.transform.GetChild(i);
                    TreeViewItem childNode      = AddGameObjectToHierarchy(childTransform.gameObject, rootGameObject, animationClip, node);
                    if (childNode != null)
                    {
                        childNodes.Add(childNode);
                    }
                }
            }

            TreeViewUtility.SetChildParentReferences(childNodes, node);
            return(node);
        }
        private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, TreeViewItem parent)
        {
            string              path         = AnimationUtility.CalculateTransformPath(gameObject.transform, this.state.activeRootGameObject.transform);
            TreeViewItem        parentNode   = new AddCurvesPopupGameObjectNode(gameObject, parent, gameObject.name);
            List <TreeViewItem> visibleItems = new List <TreeViewItem>();

            if (parent == null)
            {
                base.m_RootItem = parentNode;
            }
            EditorCurveBinding[]      animatableBindings = AnimationUtility.GetAnimatableBindings(gameObject, this.state.activeRootGameObject);
            List <EditorCurveBinding> list2 = new List <EditorCurveBinding>();

            for (int i = 0; i < animatableBindings.Length; i++)
            {
                EditorCurveBinding item = animatableBindings[i];
                list2.Add(item);
                if (item.propertyName == "m_IsActive")
                {
                    if (item.path != string.Empty)
                    {
                        TreeViewItem item2 = this.CreateNode(list2.ToArray(), parentNode);
                        if (item2 != null)
                        {
                            visibleItems.Add(item2);
                        }
                        list2.Clear();
                    }
                    else
                    {
                        list2.Clear();
                    }
                }
                else
                {
                    bool flag  = i == (animatableBindings.Length - 1);
                    bool flag2 = false;
                    if (!flag)
                    {
                        flag2 = animatableBindings[i + 1].type != item.type;
                    }
                    if (AnimationWindowUtility.IsCurveCreated(this.state.activeAnimationClip, item))
                    {
                        list2.Remove(item);
                    }
                    if ((flag || flag2) && (list2.Count > 0))
                    {
                        visibleItems.Add(this.AddAnimatableObjectToHierarchy(this.state.activeRootGameObject, list2.ToArray(), parentNode, path));
                        list2.Clear();
                    }
                }
            }
            if (showEntireHierarchy)
            {
                for (int j = 0; j < gameObject.transform.childCount; j++)
                {
                    Transform    child = gameObject.transform.GetChild(j);
                    TreeViewItem item3 = this.AddGameObjectToHierarchy(child.gameObject, parentNode);
                    if (item3 != null)
                    {
                        visibleItems.Add(item3);
                    }
                }
            }
            TreeViewUtility.SetChildParentReferences(visibleItems, parentNode);
            return(parentNode);
        }
        private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, GameObject rootGameObject, AnimationClip animationClip, TreeViewItem parent)
        {
            string              path         = AnimationUtility.CalculateTransformPath(gameObject.transform, rootGameObject.transform);
            TreeViewItem        treeViewItem = new AddCurvesPopupGameObjectNode(gameObject, parent, gameObject.name);
            List <TreeViewItem> list         = new List <TreeViewItem>();

            if (this.m_RootItem == null)
            {
                this.m_RootItem = treeViewItem;
            }
            EditorCurveBinding[]      animatableBindings = AnimationUtility.GetAnimatableBindings(gameObject, rootGameObject);
            List <EditorCurveBinding> list2 = new List <EditorCurveBinding>();

            for (int i = 0; i < animatableBindings.Length; i++)
            {
                EditorCurveBinding editorCurveBinding = animatableBindings[i];
                list2.Add(editorCurveBinding);
                if (editorCurveBinding.propertyName == "m_IsActive")
                {
                    if (editorCurveBinding.path != "")
                    {
                        TreeViewItem treeViewItem2 = this.CreateNode(list2.ToArray(), treeViewItem);
                        if (treeViewItem2 != null)
                        {
                            list.Add(treeViewItem2);
                        }
                        list2.Clear();
                    }
                    else
                    {
                        list2.Clear();
                    }
                }
                else
                {
                    bool flag  = i == animatableBindings.Length - 1;
                    bool flag2 = false;
                    if (!flag)
                    {
                        flag2 = (animatableBindings[i + 1].type != editorCurveBinding.type);
                    }
                    if (AnimationWindowUtility.IsCurveCreated(animationClip, editorCurveBinding))
                    {
                        list2.Remove(editorCurveBinding);
                    }
                    if (editorCurveBinding.type == typeof(Animator) && editorCurveBinding.propertyName == "m_Enabled")
                    {
                        list2.Remove(editorCurveBinding);
                    }
                    if ((flag || flag2) && list2.Count > 0)
                    {
                        list.Add(this.AddAnimatableObjectToHierarchy(list2.ToArray(), treeViewItem, path));
                        list2.Clear();
                    }
                }
            }
            if (AddCurvesPopupHierarchyDataSource.showEntireHierarchy)
            {
                for (int j = 0; j < gameObject.transform.childCount; j++)
                {
                    Transform    child         = gameObject.transform.GetChild(j);
                    TreeViewItem treeViewItem3 = this.AddGameObjectToHierarchy(child.gameObject, rootGameObject, animationClip, treeViewItem);
                    if (treeViewItem3 != null)
                    {
                        list.Add(treeViewItem3);
                    }
                }
            }
            TreeViewUtility.SetChildParentReferences(list, treeViewItem);
            return(treeViewItem);
        }
		private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, TreeViewItem parent)
		{
			string path = AnimationUtility.CalculateTransformPath(gameObject.transform, this.state.m_RootGameObject.transform);
			TreeViewItem treeViewItem = new AddCurvesPopupGameObjectNode(gameObject, parent, gameObject.name);
			List<TreeViewItem> list = new List<TreeViewItem>();
			if (parent == null)
			{
				this.m_RootItem = treeViewItem;
			}
			EditorCurveBinding[] animatableBindings = AnimationUtility.GetAnimatableBindings(gameObject, this.state.m_RootGameObject);
			List<EditorCurveBinding> list2 = new List<EditorCurveBinding>();
			for (int i = 0; i < animatableBindings.Length; i++)
			{
				EditorCurveBinding editorCurveBinding = animatableBindings[i];
				list2.Add(editorCurveBinding);
				if (editorCurveBinding.propertyName == "m_IsActive")
				{
					if (editorCurveBinding.path != string.Empty)
					{
						TreeViewItem treeViewItem2 = this.CreateNode(list2.ToArray(), treeViewItem);
						if (treeViewItem2 != null)
						{
							list.Add(treeViewItem2);
						}
						list2.Clear();
					}
					else
					{
						list2.Clear();
					}
				}
				else
				{
					bool flag = i == animatableBindings.Length - 1;
					bool flag2 = false;
					if (!flag)
					{
						flag2 = (animatableBindings[i + 1].type != editorCurveBinding.type);
					}
					if (AnimationWindowUtility.IsCurveCreated(this.state.m_ActiveAnimationClip, editorCurveBinding))
					{
						list2.Remove(editorCurveBinding);
					}
					if ((flag || flag2) && list2.Count > 0)
					{
						list.Add(this.AddAnimatableObjectToHierarchy(this.state.m_RootGameObject, list2.ToArray(), treeViewItem, path));
						list2.Clear();
					}
				}
			}
			if (AddCurvesPopupHierarchyDataSource.showEntireHierarchy)
			{
				for (int j = 0; j < gameObject.transform.childCount; j++)
				{
					Transform child = gameObject.transform.GetChild(j);
					TreeViewItem treeViewItem3 = this.AddGameObjectToHierarchy(child.gameObject, treeViewItem);
					if (treeViewItem3 != null)
					{
						list.Add(treeViewItem3);
					}
				}
			}
			TreeViewUtility.SetChildParentReferences(list, treeViewItem);
			return treeViewItem;
		}