/* This file is part of the "Camera Composition" editor tool by Jordan Cassady. * You are only permitted to use this software if purchased and downloaded from * the Unity Asset Store. You shall not sell, license, transfer, distribute or * otherwise make this software available to any third party. */ // You are only permitted to use this package if purchased and downloaded using UnityEngine; using UnityEngine.UI; namespace JordanCassady { /// /// Provide access to the composition overlay properties and methods for /// manipulating the Image component from the editor window. /// [RequireComponent(typeof(Image))] public class CompositionOverlay : MonoBehaviour { #region PROPERTIES public bool IsActive { get { return GetComponent().enabled; } } public float Opacity { get { return GetComponent().color.a; } } #endregion public void Activate(bool activate) { GetComponent().enabled = activate; } /// /// Invert line color from white to black or vice versa. /// /// /// public bool InvertLineColor(bool invert) { if (invert) { GetComponent().color = Color.black; } else { GetComponent().color = Color.white; } return invert; } /// /// Update the grid overlay opacity by changing the Image alpha value. /// /// public void UpdateOpacity(float alpha) { var image = GetComponent(); GetComponent().color = new Color(image.color.r, image.color.g, image.color.b, alpha); } /// /// Update the orientation of the overlay image. /// /// / public void Position(string orientation) { if (orientation == "Bottom Right") { GetComponent().transform.rotation = Quaternion.Euler(0, 0, 0); } else if (orientation == "Bottom Left") { GetComponent().transform.rotation = Quaternion.Euler(-180, 0, -180); } else if (orientation == "Top Right") { GetComponent().transform.rotation = Quaternion.Euler(-180, 0, 0); } else if (orientation == "Top Left") { GetComponent().transform.rotation = Quaternion.Euler(0, 0, -180); } } } }