Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static bool IsInteractive(this Selectable Control)
- {
- return Control.interactable;
- }
- public const float InteractiveGrayAmount = 0.5f;
- public static bool MakeInteractive(this Selectable Control, bool makeInteractive, float amount = InteractiveGrayAmount)
- { // similar to interactable, but it grays out the children of the control too
- float Multiplier = 0.0f;
- if (!makeInteractive && Control.interactable)
- Multiplier = amount; // lower alpha
- else if (makeInteractive && !Control.interactable)
- Multiplier = 1.0f / amount; // raise alpha again
- if (Multiplier > 0.0f)
- { // just lower or raise the alpha of all children by amount
- Control.interactable = makeInteractive;
- foreach (var G in Control.transform.GetComponentsInChildren<Graphic>())
- if (G != Control.targetGraphic)
- G.CrossFadeAlpha(G.canvasRenderer.GetAlpha() * Multiplier, Control.colors.fadeDuration, true);
- }
- return IsInteractive(Control);
- }
Advertisement
Add Comment
Please, Sign In to add comment