Highlighter.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace HighlightingSystem
  6. {
  7. public enum LoopMode
  8. {
  9. Once,
  10. Loop,
  11. PingPong,
  12. ClampForever,
  13. }
  14. public enum Easing
  15. {
  16. Linear,
  17. QuadIn,
  18. QuadOut,
  19. QuadInOut,
  20. CubicIn,
  21. CubicOut,
  22. CubicInOut,
  23. SineIn,
  24. SineOut,
  25. SineInOut,
  26. }
  27. public enum RendererFilterMode
  28. {
  29. None,
  30. Include,
  31. Exclude,
  32. }
  33. [AddComponentMenu("Highlighting System/Highlighter", 0)]
  34. public class Highlighter : HighlighterCore
  35. {
  36. #region Constants
  37. protected const float HALFPI = Mathf.PI * 0.5f;
  38. #endregion
  39. #region Inspector Fields
  40. /* General */
  41. /// <summary>
  42. /// When set to true - highlighting will be rendered on top of all other geometry.
  43. /// </summary>
  44. public bool overlay
  45. {
  46. get { return _overlay; }
  47. set { _overlay = value; }
  48. }
  49. /// <summary>
  50. /// Controls occluder mode.
  51. /// </summary>
  52. public bool occluder
  53. {
  54. get { return _occluder; }
  55. set { _occluder = value; }
  56. }
  57. /* Tween */
  58. public bool tween
  59. {
  60. get { return _tween; }
  61. set { TweenSet(value); }
  62. }
  63. public Gradient tweenGradient
  64. {
  65. get { return _tweenGradient; }
  66. set { _tweenGradient = value; }
  67. }
  68. public float tweenDuration
  69. {
  70. get { return _tweenDuration; }
  71. set { _tweenDuration = value; ValidateRanges(); }
  72. }
  73. public float tweenDelay
  74. {
  75. get { return _tweenDelay; }
  76. set { _tweenDelay = value; }
  77. }
  78. public bool tweenUseUnscaledTime
  79. {
  80. get { return _tweenUseUnscaledTime; }
  81. set
  82. {
  83. if (_tweenUseUnscaledTime != value)
  84. {
  85. float delta = GetTweenTime() - _tweenStart;
  86. _tweenUseUnscaledTime = value;
  87. _tweenStart = GetTweenTime() - delta;
  88. }
  89. }
  90. }
  91. public LoopMode tweenLoop
  92. {
  93. get { return _tweenLoop; }
  94. set { _tweenLoop = value; }
  95. }
  96. public Easing tweenEasing
  97. {
  98. get { return _tweenEasing; }
  99. set { _tweenEasing = value; }
  100. }
  101. public bool tweenReverse
  102. {
  103. get { return _tweenReverse; }
  104. set { _tweenReverse = value; }
  105. }
  106. public int tweenRepeatCount
  107. {
  108. get { return _tweenRepeatCount; }
  109. set { _tweenRepeatCount = value; }
  110. }
  111. /* Constant */
  112. public bool constant
  113. {
  114. get { return _constant; }
  115. set { ConstantSet(value); }
  116. }
  117. public Color constantColor
  118. {
  119. get { return _constantColor; }
  120. set { _constantColor = value; }
  121. }
  122. public float constantFadeTime
  123. {
  124. set
  125. {
  126. _constantFadeInTime = value;
  127. _constantFadeOutTime = value;
  128. ValidateRanges();
  129. ConstantSet();
  130. }
  131. }
  132. public float constantFadeInTime
  133. {
  134. get { return _constantFadeInTime; }
  135. set
  136. {
  137. _constantFadeInTime = value;
  138. ValidateRanges();
  139. if (_constant) { ConstantSet(); }
  140. }
  141. }
  142. public float constantFadeOutTime
  143. {
  144. get { return _constantFadeOutTime; }
  145. set
  146. {
  147. _constantFadeOutTime = value;
  148. ValidateRanges();
  149. if (!_constant) { ConstantSet(); }
  150. }
  151. }
  152. public bool constantUseUnscaledTime
  153. {
  154. get { return _constantUseUnscaledTime; }
  155. set
  156. {
  157. if (_constantUseUnscaledTime != value)
  158. {
  159. float delta = GetConstantTime() - _constantStart;
  160. _constantUseUnscaledTime = value;
  161. _constantStart = GetConstantTime() - delta;
  162. }
  163. }
  164. }
  165. public Easing constantEasing
  166. {
  167. get { return _constantEasing; }
  168. set { _constantEasing = value; }
  169. }
  170. public RendererFilterMode filterMode
  171. {
  172. get { return _filterMode; }
  173. set
  174. {
  175. if (_filterMode != value)
  176. {
  177. _filterMode = value;
  178. // Update highlighted Renderers
  179. SetDirty();
  180. }
  181. }
  182. }
  183. /// <summary>
  184. /// Make sure to trigger SetDirty() after modifying this list
  185. /// </summary>
  186. public List<Transform> filterList
  187. {
  188. get { return _filterList; }
  189. }
  190. protected override RendererFilter rendererFilterToUse
  191. {
  192. get
  193. {
  194. if (rendererFilter != null)
  195. {
  196. return rendererFilter;
  197. }
  198. else if (_filterMode == RendererFilterMode.None)
  199. {
  200. return globalRendererFilter != null ? globalRendererFilter : DefaultRendererFilter;
  201. }
  202. else if (_filterMode == RendererFilterMode.Include)
  203. {
  204. return TransformFilterInclude;
  205. }
  206. else if (_filterMode == RendererFilterMode.Exclude)
  207. {
  208. return TransformFilterExclude;
  209. }
  210. // Should never happen
  211. return DefaultRendererFilter;
  212. }
  213. }
  214. #endregion
  215. #region Protected Fields
  216. // General
  217. [SerializeField] protected bool _overlay;
  218. [SerializeField] protected bool _occluder;
  219. // Hover (do not serialize this!)
  220. protected Color _hoverColor = Color.red;
  221. protected int _hoverFrame = -1;
  222. // Tween
  223. [SerializeField] protected bool _tween = false;
  224. [SerializeField] protected Gradient _tweenGradient = new Gradient()
  225. {
  226. colorKeys = new GradientColorKey[]
  227. {
  228. new GradientColorKey(new Color(0f, 1f, 1f, 1f), 0f),
  229. new GradientColorKey(new Color(0f, 1f, 1f, 1f), 1f),
  230. },
  231. alphaKeys = new GradientAlphaKey[]
  232. {
  233. new GradientAlphaKey(0f, 0f),
  234. new GradientAlphaKey(1f, 1f),
  235. }
  236. };
  237. [SerializeField] protected float _tweenDuration = 1f;
  238. [SerializeField] protected bool _tweenReverse = false;
  239. [SerializeField] protected LoopMode _tweenLoop = LoopMode.PingPong;
  240. [SerializeField] protected Easing _tweenEasing = Easing.Linear;
  241. [SerializeField] protected float _tweenDelay = 0f;
  242. [SerializeField] protected int _tweenRepeatCount = -1;
  243. [SerializeField] protected bool _tweenUseUnscaledTime = false;
  244. // Constant highlighting mode (with optional fade in/out transition)
  245. [SerializeField] protected bool _constant = false;
  246. [SerializeField] protected Color _constantColor = Color.yellow;
  247. [SerializeField] protected float _constantFadeInTime = 0.1f;
  248. [SerializeField] protected float _constantFadeOutTime = 0.25f;
  249. [SerializeField] protected Easing _constantEasing = Easing.Linear;
  250. [SerializeField] protected bool _constantUseUnscaledTime = false;
  251. [SerializeField] protected RendererFilterMode _filterMode = RendererFilterMode.None;
  252. [SerializeField] protected List<Transform> _filterList = new List<Transform>();
  253. // Runtime only (do not serialize this!)
  254. protected bool _tweenEnabled;
  255. protected float _tweenStart; // Time when the tween has started
  256. protected bool _constantEnabled;
  257. protected float _constantStart;
  258. protected float _constantDuration;
  259. #endregion
  260. #region Protected Accessors
  261. protected bool hover
  262. {
  263. get { return _hoverFrame == Time.frameCount; }
  264. set { _hoverFrame = value ? Time.frameCount : -1; }
  265. }
  266. // constantValue is always increasing from 0 to 1 (for both fade in and out transitions)
  267. protected float constantValue
  268. {
  269. get { return _constantDuration > 0f ? Mathf.Clamp01((GetConstantTime() - _constantStart) / _constantDuration) : 1f; }
  270. }
  271. #endregion
  272. #region MonoBehaviour
  273. //
  274. protected virtual void OnDidApplyAnimationProperties()
  275. {
  276. ValidateAll();
  277. }
  278. #if UNITY_EDITOR
  279. //
  280. void OnValidate()
  281. {
  282. ValidateAll();
  283. }
  284. //
  285. void Reset()
  286. {
  287. ValidateAll();
  288. }
  289. #endif
  290. #endregion
  291. #region MonoBehaviour Overrides
  292. //
  293. protected override void OnEnableSafe()
  294. {
  295. ValidateAll();
  296. }
  297. //
  298. protected override void OnDisableSafe()
  299. {
  300. // Make sure transition won't continue if component will be re-enabled
  301. _tweenEnabled = false;
  302. _constantEnabled = false;
  303. _constantStart = GetConstantTime() - _constantDuration;
  304. }
  305. #endregion
  306. #region Validation
  307. //
  308. protected void ValidateAll()
  309. {
  310. ValidateRanges();
  311. TweenSet();
  312. ConstantSet();
  313. SetDirty();
  314. }
  315. //
  316. protected void ValidateRanges()
  317. {
  318. if (_tweenDuration < 0f) { _tweenDuration = 0f; }
  319. if (_constantFadeInTime < 0f) { _constantFadeInTime = 0f; }
  320. if (_constantFadeOutTime < 0f) { _constantFadeInTime = 0f; }
  321. }
  322. #endregion
  323. #region Public Methods
  324. /// <summary>
  325. /// Turn on one-frame highlighting with specified color.
  326. /// Can be called multiple times per update, color only from the latest call will be used.
  327. /// </summary>
  328. /// <param name='color'>
  329. /// Highlighting color.
  330. /// </param>
  331. public void Hover(Color color)
  332. {
  333. _hoverColor = color;
  334. hover = true;
  335. }
  336. /// <summary>
  337. /// Fade in constant highlighting using specified transition duration.
  338. /// </summary>
  339. /// <param name="time">
  340. /// Transition time.
  341. /// </param>
  342. public void ConstantOn(float fadeTime = 0.25f)
  343. {
  344. ConstantSet(fadeTime, true);
  345. }
  346. /// <summary>
  347. /// Fade in constant highlighting using specified color and transition duration.
  348. /// </summary>
  349. /// <param name="color">
  350. /// Constant highlighting color.
  351. /// </param>
  352. /// <param name="time">
  353. /// Transition duration.
  354. /// </param>
  355. public void ConstantOn(Color color, float fadeTime = 0.25f)
  356. {
  357. _constantColor = color;
  358. ConstantSet(fadeTime, true);
  359. }
  360. /// <summary>
  361. /// Fade out constant highlighting using specified transition duration.
  362. /// </summary>
  363. /// <param name="time">
  364. /// Transition time.
  365. /// </param>
  366. public void ConstantOff(float fadeTime = 0.25f)
  367. {
  368. ConstantSet(fadeTime, false);
  369. }
  370. /// <summary>
  371. /// Switch constant highlighting using specified transition duration.
  372. /// </summary>
  373. /// <param name="time">
  374. /// Transition time.
  375. /// </param>
  376. public void ConstantSwitch(float fadeTime = 0.25f)
  377. {
  378. ConstantSet(fadeTime, !_constant);
  379. }
  380. /// <summary>
  381. /// Turn on constant highlighting immediately (without fading in).
  382. /// </summary>
  383. public void ConstantOnImmediate()
  384. {
  385. ConstantSet(0f, true);
  386. }
  387. /// <summary>
  388. /// Turn on constant highlighting using specified color immediately (without fading in).
  389. /// </summary>
  390. /// <param name='color'>
  391. /// Constant highlighting color.
  392. /// </param>
  393. public void ConstantOnImmediate(Color color)
  394. {
  395. _constantColor = color;
  396. ConstantSet(0f, true);
  397. }
  398. /// <summary>
  399. /// Turn off constant highlighting immediately (without fading out).
  400. /// </summary>
  401. public void ConstantOffImmediate()
  402. {
  403. ConstantSet(0f, false);
  404. }
  405. /// <summary>
  406. /// Switch constant highlighting immediately (without fading in/out).
  407. /// </summary>
  408. public void ConstantSwitchImmediate()
  409. {
  410. ConstantSet(0f, !_constant);
  411. }
  412. /// <summary>
  413. /// Turn off all types of highlighting (occlusion mode remains intact).
  414. /// </summary>
  415. public void Off()
  416. {
  417. hover = false;
  418. TweenSet(false);
  419. ConstantSet(0f, false);
  420. }
  421. //
  422. public void TweenStart()
  423. {
  424. TweenSet(true);
  425. }
  426. //
  427. public void TweenStop()
  428. {
  429. TweenSet(false);
  430. }
  431. // Updates tween state. (!) Sets _tween value.
  432. public void TweenSet(bool value)
  433. {
  434. _tween = value;
  435. if (_tweenEnabled != _tween)
  436. {
  437. _tweenEnabled = _tween;
  438. _tweenStart = GetTweenTime();
  439. }
  440. }
  441. // Updates constant state. (!) Sets _constant value.
  442. public void ConstantSet(float fadeTime, bool value)
  443. {
  444. // Order matters. Should always set _constantDuration prior to _constantEnabled
  445. // Transition duration
  446. if (fadeTime < 0f) { fadeTime = 0f; }
  447. if (_constantDuration != fadeTime)
  448. {
  449. float timeNow = GetConstantTime();
  450. // Recalculate start time if duration changed
  451. _constantStart = _constantDuration > 0f ? timeNow - (fadeTime / _constantDuration) * (timeNow - _constantStart) : timeNow - fadeTime;
  452. _constantDuration = fadeTime;
  453. }
  454. // Transition target
  455. _constant = value;
  456. if (_constantEnabled != _constant)
  457. {
  458. _constantEnabled = _constant;
  459. // Recalculate start time if value changed
  460. _constantStart = GetConstantTime() - _constantDuration * (1f - constantValue);
  461. }
  462. }
  463. #endregion
  464. #region Protected Methods
  465. // Helper
  466. protected void TweenSet()
  467. {
  468. TweenSet(_tween);
  469. }
  470. // Helper
  471. protected void ConstantSet()
  472. {
  473. ConstantSet(_constant);
  474. }
  475. // Helper
  476. protected void ConstantSet(bool value)
  477. {
  478. ConstantSet(value ? constantFadeInTime : _constantFadeOutTime, value);
  479. }
  480. // Updates highlighting color
  481. protected override void UpdateHighlighting()
  482. {
  483. // Hover
  484. if (hover)
  485. {
  486. color = _hoverColor;
  487. mode = _overlay ? HighlighterMode.Overlay : HighlighterMode.Default;
  488. return;
  489. }
  490. // Tween
  491. if (_tweenEnabled)
  492. {
  493. float delta = GetTweenTime() - (_tweenStart + _tweenDelay);
  494. if (delta >= 0f)
  495. {
  496. float t = _tweenDuration > 0f ? delta / _tweenDuration : 0f;
  497. t = Loop(t, _tweenLoop, _tweenReverse, _tweenRepeatCount);
  498. if (t >= 0f)
  499. {
  500. t = Ease(t, _tweenEasing);
  501. color = _tweenGradient.Evaluate(t);
  502. mode = _overlay ? HighlighterMode.Overlay : HighlighterMode.Default;
  503. return;
  504. }
  505. }
  506. }
  507. // Constant
  508. float c = _constantEnabled ? constantValue : 1f - constantValue;
  509. if (c > 0f)
  510. {
  511. c = Ease(c, _constantEasing);
  512. color = _constantColor;
  513. color.a *= c;
  514. mode = _overlay ? HighlighterMode.Overlay : HighlighterMode.Default;
  515. return;
  516. }
  517. // Occluder
  518. if (_occluder)
  519. {
  520. mode = HighlighterMode.Occluder;
  521. return;
  522. }
  523. // Disabled
  524. mode = HighlighterMode.Disabled;
  525. }
  526. #endregion
  527. #region Protected Methods
  528. //
  529. protected bool TransformFilterInclude(Renderer renderer, List<int> submeshIndices)
  530. {
  531. Transform child = renderer.transform;
  532. for (int i = 0; i < _filterList.Count; i++)
  533. {
  534. Transform parent = _filterList[i];
  535. if (parent == null) { continue; }
  536. // Highlight if child of inclusion list transform
  537. if (child.IsChildOf(parent))
  538. {
  539. // Highlight all submeshes
  540. submeshIndices.Add(-1);
  541. return true;
  542. }
  543. }
  544. return false;
  545. }
  546. //
  547. protected bool TransformFilterExclude(Renderer renderer, List<int> submeshIndices)
  548. {
  549. Transform child = renderer.transform;
  550. for (int i = 0; i < _filterList.Count; i++)
  551. {
  552. Transform parent = _filterList[i];
  553. if (parent == null) { continue; }
  554. // Do not highlight if child of exclusion list transform
  555. if (child.IsChildOf(parent)) { return false; }
  556. }
  557. // Highlight all submeshes
  558. submeshIndices.Add(-1);
  559. return true;
  560. }
  561. //
  562. protected float Loop(float x, LoopMode loop, bool reverse = false, int repeatCount = -1)
  563. {
  564. float y = -1f;
  565. switch (loop)
  566. {
  567. default:
  568. case LoopMode.Once:
  569. if (x >= 0f && x <= 1f) { y = x; }
  570. break;
  571. case LoopMode.Loop:
  572. int n1 = Mathf.FloorToInt(x);
  573. if (repeatCount < 0 || n1 < repeatCount)
  574. {
  575. y = x - n1;
  576. }
  577. break;
  578. case LoopMode.PingPong:
  579. // Performs 0-1-0 transition in tweenDuration time
  580. //int n2 = Mathf.FloorToInt(x);
  581. //if (repeatCount < 0 || n2 < repeatCount)
  582. //{
  583. // y = 1f - Mathf.Abs((x - n2) * 2f - 1f);
  584. //}
  585. // Performs 0-1-0 transition in 2 * tweenDuration time,
  586. // so the 0-1 transition is performed with the same speed as in Loop mode.
  587. int n2 = Mathf.FloorToInt(x * 0.5f);
  588. if (repeatCount < 0 || n2 < repeatCount)
  589. {
  590. y = 1f - Mathf.Abs(x - n2 * 2f - 1f);
  591. }
  592. break;
  593. case LoopMode.ClampForever:
  594. y = Mathf.Clamp01(x);
  595. break;
  596. }
  597. // Reverse. Check y for positive value since there is no loop if it's negative.
  598. if (y >= 0f && reverse) { y = 1f - y; }
  599. return y;
  600. }
  601. //
  602. protected float Ease(float x, Easing easing)
  603. {
  604. x = Mathf.Clamp01(x);
  605. float y;
  606. switch (easing)
  607. {
  608. // Linear
  609. default:
  610. case Easing.Linear:
  611. y = x;
  612. break;
  613. // Quad
  614. case Easing.QuadIn:
  615. y = x * x;
  616. break;
  617. case Easing.QuadOut:
  618. y = -x * (x - 2f);
  619. break;
  620. case Easing.QuadInOut:
  621. y = x < 0.5f ? 2f * x * x : 2f * x * (2f - x) - 1f;
  622. break;
  623. // Cubic
  624. case Easing.CubicIn:
  625. y = x * x * x;
  626. break;
  627. case Easing.CubicOut:
  628. x = x - 1f;
  629. y = x * x * x + 1f;
  630. break;
  631. case Easing.CubicInOut:
  632. if (x < 0.5f)
  633. {
  634. y = 4f * x * x * x;
  635. }
  636. else
  637. {
  638. x = 2f * x - 2f;
  639. y = 0.5f * (x * x * x + 2f);
  640. }
  641. break;
  642. // Sine
  643. case Easing.SineIn:
  644. y = 1f - Mathf.Cos(x * HALFPI);
  645. break;
  646. case Easing.SineOut:
  647. y = Mathf.Sin(x * HALFPI);
  648. break;
  649. case Easing.SineInOut:
  650. y = -0.5f * (Mathf.Cos(x * Mathf.PI) - 1f);
  651. break;
  652. //y = x * x * (3f - 2f * x);
  653. }
  654. return y;
  655. }
  656. //
  657. protected float GetTweenTime()
  658. {
  659. return _tweenUseUnscaledTime ? Time.unscaledTime : Time.time;
  660. }
  661. //
  662. protected float GetConstantTime()
  663. {
  664. return _constantUseUnscaledTime ? Time.unscaledTime : Time.time;
  665. }
  666. #endregion
  667. #region Static Methods
  668. // Color helper
  669. static public Color HSVToRGB(float hue, float saturation, float value)
  670. {
  671. float x = 6f * Mathf.Clamp01(hue);
  672. saturation = Mathf.Clamp01(saturation);
  673. value = Mathf.Clamp01(value);
  674. return new Color
  675. (
  676. value * (1f + (Mathf.Clamp01(Mathf.Max(2f - x, x - 4f)) - 1f) * saturation),
  677. value * (1f + (Mathf.Clamp01(Mathf.Min(x, 4f - x)) - 1f) * saturation),
  678. value * (1f + (Mathf.Clamp01(Mathf.Min(x - 2f, 6f - x)) - 1f) * saturation)
  679. );
  680. }
  681. #endregion
  682. #region DEPRECATED
  683. private GradientColorKey[] flashingColorKeys = new GradientColorKey[]
  684. {
  685. new GradientColorKey(new Color(0f, 1f, 1f, 0f), 0f),
  686. new GradientColorKey(new Color(0f, 1f, 1f, 1f), 1f)
  687. };
  688. private GradientAlphaKey[] flashingAlphaKeys = new GradientAlphaKey[]
  689. {
  690. new GradientAlphaKey(1f, 0f),
  691. new GradientAlphaKey(1f, 1f),
  692. };
  693. /// <summary>
  694. /// DEPRECATED. Use hover = true; instead.
  695. /// </summary>
  696. [System.Obsolete]
  697. public void On()
  698. {
  699. hover = true;
  700. }
  701. /// <summary>
  702. /// DEPRECATED. Use Hover(Color color) instead.
  703. /// </summary>
  704. [System.Obsolete]
  705. public void On(Color color)
  706. {
  707. Hover(color);
  708. }
  709. /// <summary>
  710. /// DEPRECATED. Use Hover(new Color(1f, 0f, 0f, 1f)); instead.
  711. /// </summary>
  712. [System.Obsolete]
  713. public void OnParams(Color color)
  714. {
  715. _hoverColor = color;
  716. }
  717. /// <summary>
  718. /// DEPRECATED. Use constantColor = new Color(0f, 1f, 1f, 1f); instead.
  719. /// </summary>
  720. [System.Obsolete]
  721. public void ConstantParams(Color color)
  722. {
  723. _constantColor = color;
  724. }
  725. /// <summary>
  726. /// DEPRECATED. Use tweenGradient and tweenDuration instead.
  727. /// </summary>
  728. [System.Obsolete]
  729. public void FlashingParams(Color color1, Color color2, float freq)
  730. {
  731. flashingColorKeys[0].color = color1;
  732. flashingColorKeys[1].color = color2;
  733. _tweenGradient.SetKeys(flashingColorKeys, flashingAlphaKeys);
  734. _tweenDuration = 1f / freq;
  735. }
  736. /// <summary>
  737. /// DEPRECATED. Use TweenStart() instead.
  738. /// </summary>
  739. [System.Obsolete]
  740. public void FlashingOn()
  741. {
  742. TweenSet(true);
  743. }
  744. /// <summary>
  745. /// DEPRECATED. Use tweenGradient instead.
  746. /// </summary>
  747. [System.Obsolete]
  748. public void FlashingOn(Color color1, Color color2)
  749. {
  750. flashingColorKeys[0].color = color1;
  751. flashingColorKeys[1].color = color2;
  752. _tweenGradient.SetKeys(flashingColorKeys, flashingAlphaKeys);
  753. TweenSet(true);
  754. }
  755. /// <summary>
  756. /// DEPRECATED. Use tweenGradient and tweenDuration instead.
  757. /// </summary>
  758. [System.Obsolete]
  759. public void FlashingOn(Color color1, Color color2, float freq)
  760. {
  761. flashingColorKeys[0].color = color1;
  762. flashingColorKeys[1].color = color2;
  763. _tweenGradient.SetKeys(flashingColorKeys, flashingAlphaKeys);
  764. _tweenDuration = 1f / freq;
  765. TweenSet(true);
  766. }
  767. /// <summary>
  768. /// DEPRECATED. Use tweenDuration instead.
  769. /// </summary>
  770. [System.Obsolete]
  771. public void FlashingOn(float freq)
  772. {
  773. _tweenDuration = 1f / freq;
  774. TweenSet(true);
  775. }
  776. /// <summary>
  777. /// DEPRECATED. Use TweenStop() instead.
  778. /// </summary>
  779. [System.Obsolete]
  780. public void FlashingOff()
  781. {
  782. TweenSet(false);
  783. }
  784. /// <summary>
  785. /// DEPRECATED. Use TweenStart() and TweenStop() instead.
  786. /// </summary>
  787. [System.Obsolete]
  788. public void FlashingSwitch()
  789. {
  790. tween = !tween;
  791. }
  792. #endregion
  793. }
  794. }