Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using DG.Tweening.Timeline.Core;
- using DG.Tweening.Timeline.Core.Plugins;
- using UnityEngine;
- namespace Demigiant.DOTweenExtended
- {
- #if UNITY_EDITOR
- [UnityEditor.InitializeOnLoad]
- #endif
- public static class Test_ExtraVisualTweenPlugins
- {
- #if UNITY_EDITOR
- static Test_ExtraVisualTweenPlugins()
- {
- // Used only to register plugins to be displayed in editor's timeline (runtime uses Register method directly)
- if (!UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode) Register();
- }
- #endif
- [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
- static void Register()
- {
- DOVisualPluginsManager.RegisterGlobalTweenPlugins(GetGlobalTweenPlugin, "Custom Global");
- DOVisualPluginsManager.RegisterTweenPlugins(GetTweenPlugin);
- }
- static DOVisualTweenPlugin GetGlobalTweenPlugin(string id)
- {
- switch (id) {
- case "Custom Global":
- return DOVisualPluginsManager.CacheAndReturnGlobal(id,
- new PlugDataGlobalTween("Custom Time/Time Scale", ()=> Time.timeScale, x => Time.timeScale = x)
- );
- }
- return null;
- }
- static DOVisualTweenPlugin GetTweenPlugin(Type targetType, string targetTypeFullName)
- {
- if (targetType == typeof(Test_CustomComponent)) {
- return DOVisualPluginsManager.CacheAndReturn(targetType,
- new PlugDataTween("A Float", (c,s,i) => ()=> ((Test_CustomComponent)c).aFloat, (c,s,i) => x => ((Test_CustomComponent)c).aFloat = x),
- new PlugDataTween("An Int", (c,s,i) => ()=> ((Test_CustomComponent)c).aInt, (c,s,i) => x => ((Test_CustomComponent)c).aInt = x),
- new PlugDataTween("A Uint", (c,s,i) => ()=> ((Test_CustomComponent)c).aUint, (c,s,i) => x => ((Test_CustomComponent)c).aUint = x),
- new PlugDataTween("A String", (c,s,i) => ()=> ((Test_CustomComponent)c).aString, (c,s,i) => x => ((Test_CustomComponent)c).aString = x),
- new PlugDataTween("A Vector2", (c,s,i) => ()=> ((Test_CustomComponent)c).aVector2, (c,s,i) => x => ((Test_CustomComponent)c).aVector2 = x),
- new PlugDataTween("A Vector3", (c,s,i) => ()=> ((Test_CustomComponent)c).aVector3, (c,s,i) => x => ((Test_CustomComponent)c).aVector3 = x),
- new PlugDataTween("A Vector4", (c,s,i) => ()=> ((Test_CustomComponent)c).aVector4, (c,s,i) => x => ((Test_CustomComponent)c).aVector4 = x),
- new PlugDataTween("A Color", (c,s,i) => ()=> ((Test_CustomComponent)c).aColor, (c,s,i) => x => ((Test_CustomComponent)c).aColor = x),
- new PlugDataTween("A Rect", (c,s,i) => ()=> ((Test_CustomComponent)c).aRect, (c,s,i) => x => ((Test_CustomComponent)c).aRect = x)
- );
- }
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement