Example #1
0
        /// <summary>
        /// Helper to add ecs actions from code.
        /// </summary>
        /// <param name="go">GameObject holder.</param>
        /// <param name="widgetName">Optional logical widget name, will be registered with OnStart type.</param>
        /// <param name="emitter">Optional emitter. If not provided - will be detected automatically.</param>
        public static T AddAction <T> (GameObject go, string widgetName = null, EcsUiEmitter emitter = null) where T : EcsUiActionBase
        {
            var action = go.AddComponent <T> ();

            if (widgetName != null)
            {
                action.WidgetName            = widgetName;
                action._nameRegistrationType = EcsUiActionNameRegistrationType.OnStart;
            }
            action.Emitter = emitter;
            return(action);
        }
Example #2
0
        void ValidateEmitter()
        {
            if (Emitter == null)
            {
                Emitter = GetComponentInParent <EcsUiEmitter> ();
            }
#if DEBUG
            if (Emitter == null)
            {
                Debug.LogError("EcsUiEmitter not found in hierarchy", this);
            }
#endif
        }