public bool IsEditable(UnityEngine.Object targetObject) { bool result; if (this.state.selection.disabled) { result = false; } else if (!this.previewing) { result = false; } else { AnimationWindowSelectionItem selectedItem = this.state.selectedItem; if (selectedItem != null) { GameObject gameObject = null; if (targetObject is Component) { gameObject = ((Component)targetObject).gameObject; } else if (targetObject is GameObject) { gameObject = (GameObject)targetObject; } if (gameObject != null) { Component closestAnimationPlayerComponentInParents = AnimationWindowUtility.GetClosestAnimationPlayerComponentInParents(gameObject.transform); if (selectedItem.animationPlayer == closestAnimationPlayerComponentInParents) { result = selectedItem.animationIsEditable; return(result); } } } result = false; } return(result); }
public static bool InitializeGameobjectForAnimation(GameObject animatedObject) { Component componentInParents = AnimationWindowUtility.GetClosestAnimationPlayerComponentInParents(animatedObject.transform); if (!((UnityEngine.Object)componentInParents == (UnityEngine.Object)null)) { return(AnimationWindowUtility.EnsureAnimationPlayerHasClip(componentInParents)); } AnimationClip newClip = AnimationWindowUtility.CreateNewClip(animatedObject.name); if ((UnityEngine.Object)newClip == (UnityEngine.Object)null) { return(false); } Component animationPlayer = AnimationWindowUtility.EnsureActiveAnimationPlayer(animatedObject); bool animationPlayerComponent = AnimationWindowUtility.AddClipToAnimationPlayerComponent(animationPlayer, newClip); if (!animationPlayerComponent) { UnityEngine.Object.DestroyImmediate((UnityEngine.Object)animationPlayer); } return(animationPlayerComponent); }
public static bool InitializeGameobjectForAnimation(GameObject animatedObject) { Component component = AnimationWindowUtility.GetClosestAnimationPlayerComponentInParents(animatedObject.transform); if (!(component == null)) { return(AnimationWindowUtility.EnsureAnimationPlayerHasClip(component)); } AnimationClip animationClip = AnimationWindowUtility.CreateNewClip(animatedObject.name); if (animationClip == null) { return(false); } component = AnimationWindowUtility.EnsureActiveAnimationPlayer(animatedObject); bool flag = AnimationWindowUtility.AddClipToAnimationPlayerComponent(component, animationClip); if (!flag) { UnityEngine.Object.DestroyImmediate(component); } return(flag); }