public static string DrawSPAnimatorFunctionPopup(Rect position, ISPAnimator controller, string functionName) { var tp = controller.GetType(); var methods = (from m in tp.GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic) let attrib = m.GetCustomAttributes(typeof(SPAnimatorMethodAttribute), true).FirstOrDefault() where attrib != null && m.GetParameters().Length == 0 select new { attrib, m }).ToArray(); if (methods.Length > 0) { var names = (from o in methods select o.m.Name).ToArray(); int index = System.Array.IndexOf(names, functionName); index = EditorGUI.Popup(position, "Function", index, names); if (index < 0) { index = 0; } return(names[index]); } else { EditorGUI.LabelField(position, "Function", "No functions found on animator"); return(string.Empty); } }
private object ResolveTargetAnimator(object arg) { var obj = _targetAnimator.GetTarget <UnityEngine.Object>(arg); ISPAnimationSource src = null; ISPAnimator spanim = null; Animation anim = null; if (ObjUtil.GetAsFromSource <ISPAnimationSource>(obj, out src)) { return(src); } if (ObjUtil.GetAsFromSource <ISPAnimator>(obj, out spanim)) { return(spanim); } if (ObjUtil.GetAsFromSource <Animation>(obj, out anim)) { return(anim); } if (_targetAnimator.ImplicityReducesEntireEntity) { var go = GameObjectUtil.FindRoot(GameObjectUtil.GetGameObjectFromSource(obj)); if (go == null) { return(null); } SPLegacyAnimController spcont; if (go.FindComponent <SPLegacyAnimController>(out spcont)) { return(spcont); } if (go.FindComponent <Animation>(out anim)) { return(anim); } } return(null); }
private object ResolveTargetAnimator(object arg) { var obj = _targetAnimator.GetTarget <UnityEngine.Object>(arg); ISPAnimationSource src = null; ISPAnimator spanim = null; Animation anim = null; if (ObjUtil.GetAsFromSource <ISPAnimationSource>(obj, out src)) { return(src); } if (ObjUtil.GetAsFromSource <ISPAnimator>(obj, out spanim)) { return(spanim); } if (ObjUtil.GetAsFromSource <Animation>(obj, out anim)) { return(anim); } if (_targetAnimator.SearchesScene || _targetAnimator.TargetsTriggerArg) { var go = GameObjectUtil.FindRoot(GameObjectUtil.GetGameObjectFromSource(obj)); if (go == null) { return(null); } SPAnimationController spcont; if (go.FindComponent <SPAnimationController>(out spcont)) { return(spcont); } if (go.FindComponent <Animation>(out anim)) { return(anim); } } /* * if(obj == null || obj is ISPAnimationSource || obj is ISPAnimator || obj is Animation) * { * return obj; * } * else if (_targetAnimator.Find != TriggerableTargetObject.FindCommand.Direct || _targetAnimator.TargetsTriggerArg) * { * var go = GameObjectUtil.FindRoot(GameObjectUtil.GetGameObjectFromSource(obj)); * if (go == null) return null; * * SPAnimationController spcont; * if (go.FindComponent<SPAnimationController>(out spcont)) * return spcont; * * Animation anim; * if (go.FindComponent<Animation>(out anim)) * return anim; * } */ return(null); }
private object ResolveTargetAnimator(object arg) { var obj = _targetAnimator.GetTarget <UnityEngine.Object>(arg); ISPAnimationSource src = null; ISPAnimator spanim = null; Animation anim = null; if (ObjUtil.GetAsFromSource <ISPAnimationSource>(obj, out src)) { return(src); } if (ObjUtil.GetAsFromSource <ISPAnimator>(obj, out spanim)) { return(spanim); } if (ObjUtil.GetAsFromSource <Animation>(obj, out anim)) { return(anim); } if (obj is SPEntity || _targetAnimator.ImplicityReducesEntireEntity) { var go = obj is SPEntity ? (obj as SPEntity).gameObject : GameObjectUtil.FindRoot(GameObjectUtil.GetGameObjectFromSource(obj)); if (go == null) { return(null); } SPAnimationController spcont; if (go.FindComponent <SPAnimationController>(out spcont)) { return(spcont); } if (go.FindComponent <Animation>(out anim)) { return(anim); } } /* * var obj = _targetAnimator.GetTarget<UnityEngine.Object>(arg); * if (obj == null || obj is SPAnimationController || obj is Animation) * { * return obj; * } * else if (_targetAnimator.ImplicityReducesEntireEntity) * { * var go = GameObjectUtil.FindRoot(GameObjectUtil.GetGameObjectFromSource(obj)); * if (go == null) return null; * * SPAnimationController spcont; * if (go.FindComponent<SPAnimationController>(out spcont)) * return spcont; * * Animation anim; * if (go.FindComponent<Animation>(out anim)) * return anim; * } */ return(null); }