Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 KB | None | 0 0
  1.     [AddComponentMenu("UX/TweenPercentBinder")]
  2.     public class TweenPercentBinder : SerializedMonoBehaviour
  3.     {
  4.         [OdinSerialize, NonSerialized, HideReferenceObjectPicker]
  5.         [ListDrawerSettings(ListElementLabelName = "Name")]
  6.         protected TweenBase[] Tweens = new TweenBase[0];
  7.     }
  8.  
  9.     public abstract class TweenBase
  10.     {
  11.         /// <summary>
  12.         ///     Editor Name
  13.         /// </summary>
  14.         public abstract string Name { get; }
  15.        
  16.         /// <summary>
  17.         ///     Called onced
  18.         /// </summary>
  19.         public abstract void Init(MonoBehaviour controller);
  20.        
  21.         /// <summary>
  22.         ///     Handle
  23.         /// </summary>
  24.         public abstract void SetPercent(float percent);
  25.     }
  26.  
  27.     public class CanvasAlpha : TweenBase
  28.     {
  29.         public override string Name
  30.         {
  31.             get
  32.             {
  33.                 return "CanvasAlpha";
  34.             }
  35.         }
  36.  
  37.         [OdinSerialize]
  38.         RangeFloat _range;
  39.  
  40.         CanvasGroup _target;
  41.  
  42.         public override void Init(MonoBehaviour controller)
  43.         {
  44.             _target = controller.GetComponent<CanvasGroup>();
  45.         }
  46.  
  47.         public override void SetPercent(float percent)
  48.         {
  49.             //  var v = Mathf.Lerp(_range.start, _range.end, percent);
  50.             // _target.alpha = v;
  51.             //  _target.interactable = v >= 1f;
  52.             //  _target.blocksRaycasts = v > 0f;
  53.         }
  54.     }
  55.  
  56.     [Serializable]
  57.     public struct RangeFloat
  58.     {
  59.         public float start;
  60.         public float end;
  61.  
  62.         public RangeFloat(float s = 0, float e = 0)
  63.         {
  64.             start = s;
  65.             end = e;
  66.         }
  67.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement