Exemple #1
0
        // Sets up singleton instance. Will remain if one does not already exist in scene
        void Awake()
        {
            if (instance == null)
            {
                DontDestroyOnLoad(gameObject);
                instance = this;
            }
            else if (instance != this)
            {
                Destroy(gameObject);
            }

            controllers = new List<Controller>();
            customColor = new CustomColor();
        }
Exemple #2
0
        /// <summary>
        /// Gets a color from a property name in CustomColor
        /// </summary>
        /// <param name="uObject">The CustomColor object to pull the property from</param>
        /// <param name="propertyName">The name of the property/color to return</param>
        /// <returns></returns>
        public static Color ColorFromProperty(CustomColor uObject, string propertyName)
        {
            PropertyInfo property = typeof(CustomColor).GetProperty(propertyName, typeof(Color));
            Color        color    = black;

            if (property != null)
            {
                color = (Color)(property.GetValue(uObject, null));
            }
            else
            {
                Debug.LogError("There is no property named " + propertyName + " in CustomColor. Returning Black by default.");
                color = black;
            }
            return(color);
        }
Exemple #3
0
 void Awake()
 {
     if (_ui)
     {
         this.GetComponent <Image>().color = CustomColor.GetColor(_color);
     }
     else
     {
         if (onlyChildren)
         {
             Renderer[] _r = this.GetComponentsInChildren <Renderer>();
             for (int i = 0; i < _r.Length; i++)
             {
                 _r[i].material.color = CustomColor.GetColor(_color);
             }
         }
         else
         {
             this.GetComponent <Renderer>().material.color = CustomColor.GetColor(_color);
         }
     }
 }
Exemple #4
0
 /// <summary>
 /// Gets a color from a property name in CustomColor
 /// </summary>
 /// <param name="uObject">The CustomColor object to pull the property from</param>
 /// <param name="propertyName">The name of the property/color to return</param>
 /// <returns></returns>
 public static Color ColorFromProperty(CustomColor uObject, string propertyName)
 {
     PropertyInfo property = typeof(CustomColor).GetProperty(propertyName, typeof(Color));
     Color color = black;
     if (property != null)
     {
         color = (Color)(property.GetValue(uObject, null));
     }
     else
     {
         Debug.LogError("There is no property named " + propertyName + " in CustomColor. Returning Black by default.");
         color =  black;
     }
     return color;
 }