public UParameterControllerEditor() { var path = InternalEditorUtility.GetEditorAssemblyPath().Replace("UnityEditor.dll", "UnityEditor.Graphs.dll"); var asmUnityEditor = Assembly.LoadFrom(path); var parameterControllerEditorType = asmUnityEditor.GetType("UnityEditor.Graphs.ParameterControllerEditor"); Assert.IsNotNull(dg_get_tool = EditorCommon.CreateGetFieldDelegate <object>(parameterControllerEditorType.GetField("tool", BindingFlags.Public | BindingFlags.Static))); Assert.IsNotNull(dg_set_m_PreviewAnimator = EditorCommon.CreateSetFieldDelegate <Animator>(parameterControllerEditorType.GetField("m_PreviewAnimator", BindingFlags.NonPublic | BindingFlags.Instance))); }
public UTimeControl(object instance) { this.instance = instance; var asmUnityEditor = Assembly.LoadFrom(InternalEditorUtility.GetEditorAssemblyPath()); var timeControlType = asmUnityEditor.GetType("UnityEditor.TimeControl"); { var fi_currentTime = timeControlType.GetField("currentTime"); dg_get_currentTime = EditorCommon.CreateGetFieldDelegate <float>(fi_currentTime); dg_set_currentTime = EditorCommon.CreateSetFieldDelegate <float>(fi_currentTime); } { var pi_nextCurrentTime = timeControlType.GetProperty("nextCurrentTime"); dg_set_nextCurrentTime = (Action <float>)Delegate.CreateDelegate(typeof(Action <float>), instance, pi_nextCurrentTime.GetSetMethod()); } { var fi_startTime = timeControlType.GetField("startTime"); dg_get_startTime = EditorCommon.CreateGetFieldDelegate <float>(fi_startTime); dg_set_startTime = EditorCommon.CreateSetFieldDelegate <float>(fi_startTime); } { var fi_stopTime = timeControlType.GetField("stopTime"); dg_get_stopTime = EditorCommon.CreateGetFieldDelegate <float>(fi_stopTime); dg_set_stopTime = EditorCommon.CreateSetFieldDelegate <float>(fi_stopTime); } { var fi_loop = timeControlType.GetField("loop"); dg_get_loop = EditorCommon.CreateGetFieldDelegate <bool>(fi_loop); dg_set_loop = EditorCommon.CreateSetFieldDelegate <bool>(fi_loop); } dg_Update = (Action)Delegate.CreateDelegate(typeof(Action), instance, timeControlType.GetMethod("Update")); { var pi_deltaTime = timeControlType.GetProperty("deltaTime"); dg_get_deltaTime = (Func <float>)Delegate.CreateDelegate(typeof(Func <float>), instance, pi_deltaTime.GetGetMethod()); dg_set_deltaTime = (Action <float>)Delegate.CreateDelegate(typeof(Action <float>), instance, pi_deltaTime.GetSetMethod()); } { var fi_m_DeltaTimeSet = timeControlType.GetField("m_DeltaTimeSet", BindingFlags.NonPublic | BindingFlags.Instance); dg_get_m_DeltaTimeSet = EditorCommon.CreateGetFieldDelegate <bool>(fi_m_DeltaTimeSet); } { var pi_playing = timeControlType.GetProperty("playing"); dg_get_playing = (Func <bool>)Delegate.CreateDelegate(typeof(Func <bool>), instance, pi_playing.GetGetMethod()); dg_set_playing = (Action <bool>)Delegate.CreateDelegate(typeof(Action <bool>), instance, pi_playing.GetSetMethod()); } }
public UAvatarPreview(AnimationClip clip, GameObject gameObject) { var asmUnityEditor = Assembly.LoadFrom(InternalEditorUtility.GetEditorAssemblyPath()); var avatarPreviewType = asmUnityEditor.GetType("UnityEditor.AvatarPreview"); Assert.IsNotNull(instance = Activator.CreateInstance(avatarPreviewType, new object[] { null, clip })); Assert.IsNotNull(fi_m_PreviewDir = avatarPreviewType.GetField("m_PreviewDir", BindingFlags.NonPublic | BindingFlags.Instance)); Assert.IsNotNull(fi_m_ZoomFactor = avatarPreviewType.GetField("m_ZoomFactor", BindingFlags.NonPublic | BindingFlags.Instance)); Assert.IsNotNull(dg_set_fps = EditorCommon.CreateSetFieldDelegate <int>(avatarPreviewType.GetField("fps"))); Assert.IsNotNull(dg_get_m_SourcePreviewMotion = EditorCommon.CreateGetFieldDelegate <AnimationClip>(avatarPreviewType.GetField("m_SourcePreviewMotion", BindingFlags.NonPublic | BindingFlags.Instance))); Assert.IsNotNull(dg_get_IKOnFeet = (Func <bool>)Delegate.CreateDelegate(typeof(Func <bool>), instance, avatarPreviewType.GetProperty("IKOnFeet").GetGetMethod())); Assert.IsNotNull(dg_get_Animator = (Func <Animator>)Delegate.CreateDelegate(typeof(Func <Animator>), instance, avatarPreviewType.GetProperty("Animator").GetGetMethod())); Assert.IsNotNull(dg_get_ShowIKOnFeetButton = (Func <bool>)Delegate.CreateDelegate(typeof(Func <bool>), instance, avatarPreviewType.GetProperty("ShowIKOnFeetButton").GetGetMethod())); Assert.IsNotNull(dg_set_ShowIKOnFeetButton = (Action <bool>)Delegate.CreateDelegate(typeof(Action <bool>), instance, avatarPreviewType.GetProperty("ShowIKOnFeetButton").GetSetMethod())); Assert.IsNotNull(dg_get_PreviewObject = (Func <GameObject>)Delegate.CreateDelegate(typeof(Func <GameObject>), instance, avatarPreviewType.GetProperty("PreviewObject").GetGetMethod())); Assert.IsNotNull(dg_get_animationClipType = (Func <ModelImporterAnimationType>)Delegate.CreateDelegate(typeof(Func <ModelImporterAnimationType>), instance, avatarPreviewType.GetProperty("animationClipType").GetGetMethod())); Assert.IsNotNull(dg_DoPreviewSettings = (Action)Delegate.CreateDelegate(typeof(Action), instance, avatarPreviewType.GetMethod("DoPreviewSettings"))); Assert.IsNotNull(dg_DoAvatarPreview = (Action <Rect, GUIStyle>)Delegate.CreateDelegate(typeof(Action <Rect, GUIStyle>), instance, avatarPreviewType.GetMethod("DoAvatarPreview"))); #if UNITY_2018_2_OR_NEWER Assert.IsNotNull(dg_OnDestroy = (Action)Delegate.CreateDelegate(typeof(Action), instance, avatarPreviewType.GetMethod("OnDisable"))); #else Assert.IsNotNull(dg_OnDestroy = (Action)Delegate.CreateDelegate(typeof(Action), instance, avatarPreviewType.GetMethod("OnDestroy"))); #endif Assert.IsNotNull(dg_SetPreview = (Action <GameObject>)Delegate.CreateDelegate(typeof(Action <GameObject>), instance, avatarPreviewType.GetMethod("SetPreview", BindingFlags.NonPublic | BindingFlags.Instance))); Assert.IsNotNull(pi_OnAvatarChangeFunc = avatarPreviewType.GetProperty("OnAvatarChangeFunc")); uAnimatorController = new UAnimatorController(); uAnimatorStateMachine = new UAnimatorStateMachine(); uAnimatorState = new UAnimatorState(); { var fi_timeControl = avatarPreviewType.GetField("timeControl"); uTimeControl = new UTimeControl(fi_timeControl.GetValue(instance)); uTimeControl.startTime = 0f; uTimeControl.stopTime = clip.length; uTimeControl.currentTime = 0f; } uAvatarPreviewSelection = new UAvatarPreviewSelection(asmUnityEditor); pi_OnAvatarChangeFunc.SetValue(instance, Delegate.CreateDelegate(pi_OnAvatarChangeFunc.PropertyType, this, GetType().GetMethod("OnAvatarChangeFunc", BindingFlags.NonPublic | BindingFlags.Instance)), null); dg_set_fps(instance, (int)clip.frameRate); dg_SetPreview(gameObject); AnimationUtility.onCurveWasModified += OnCurveWasModified; }
public UAnimationWindowState_2019_2(Assembly asmUnityEditor) : base(asmUnityEditor) { Assert.IsNotNull(dg_set_m_AllCurvesCache = EditorCommon.CreateSetFieldDelegate <IList>(animationWindowStateType.GetField("m_AllCurvesCache", BindingFlags.NonPublic | BindingFlags.Instance))); }