Example #1
0
        /// <summary>
        /// Get newly created Text asset and get/set its font.
        /// </summary>
        private void OnHierarchyChanged()
        {
            // For some reason, OnHierarchyChanged is called twice.
            if (justHeard == true)
            {
                justHeard = false;
                return;
            }

            justHeard = true;

            // Do not run while in play mode!
            if (Application.isEditor && !Application.isPlaying)
            {
                if (!IsValidObject() || GlobalTextSettings.TextSettings == null)
                {
                    return;
                }

                // New text object created, update the static list of all Text objects.
                GlobalTextSettings.UpdateTextObjects();

                var newText = Selection.activeGameObject.GetComponentInChildren <Text>(true);

                foreach (var key in GlobalTextSettings.TextSettings.SavedSettings.Keys)
                {
                    newText.ChangeProperty(key);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Checks that we have a created object (we could be deleting objects)
        /// and that the object, or its children, have Text.
        /// </summary>
        private bool IsValidObject()
        {
            if (Selection.activeGameObject == null)
            {
                // We deleted an object update the static list of all Text objects.
                GlobalTextSettings.UpdateTextObjects();

                return(false);
            }

            if (Selection.activeGameObject.GetComponentInChildren <Text>(true) == null)
            {
                return(false);
            }

            return(true);
        }