コード例 #1
0
        protected void Run(IScWidget widget)
        {
            IHandler handler = null;

            try
            {
                if (s_Handler.TryGetValue(widget.GetType(), out handler))
                {
                    handler.Run(Context, widget);
                }
                else
                {
                    FallbackRun(Context, widget);
                }
                foreach (var child in widget.GetChildren())
                {
                    Run(child);
                }
            }
            finally
            {
                if (handler != null)
                {
                    handler.Finish(Context, widget);
                }
                else
                {
                    FallbackFinish(Context, widget);
                }
            }
        }
コード例 #2
0
        protected override void FallbackPrepare(uGUIBuilder context, IScWidget widget)
        {
            var parent = context.GetEntry(widget.Parent);
            var entry  = context.GetEntry(widget);

            entry.Obj                 = new GameObject(widget.Name ?? widget.GetType().Name);
            entry.ChildRoot           = entry.Obj.AddComponent <RectTransform>();
            entry.ChildRoot.anchorMax = new Vector2(0, 1);
            entry.ChildRoot.anchorMin = new Vector2(0, 1);
            if (parent != null && parent.ChildRoot != null)
            {
                entry.Obj.transform.SetParent(parent.ChildRoot);
            }
        }
コード例 #3
0
            protected UComponent Create(uGUIBuilder context, IScWidget widget)
            {
                var parent = context.GetEntry(widget.Parent);
                var entry  = context.GetEntry(widget);

                entry.Obj                 = new GameObject(widget.Name ?? widget.GetType().Name);
                entry.ChildRoot           = entry.Obj.AddComponent <RectTransform>();
                entry.ChildRoot.anchorMax = new Vector2(0, 1);
                entry.ChildRoot.anchorMin = new Vector2(0, 1);
                if (parent != null && parent.ChildRoot != null)
                {
                    entry.Obj.transform.SetParent(parent.ChildRoot);
                }
                var ret = entry.Obj.AddComponent <UComponent>();

                entry.Component = ret;
                return(ret);
            }
コード例 #4
0
        protected void Prepare(IScWidget widget)
        {
            IHandler handler;

            if (s_Handler.TryGetValue(widget.GetType(), out handler))
            {
                handler.Prepare(Context, widget);
            }
            else
            {
                FallbackPrepare(Context, widget);
            }

            foreach (var child in widget.GetChildren())
            {
                Prepare(child);
            }
        }
コード例 #5
0
        void Run <T>(IScWidget widget, Func <TContext, IScWidget, T, IDisposable> func) where T : class
        {
            IHandler _handler;

            s_Handler.TryGetValue(widget.GetType(), out _handler);
            IDisposable disposable = null;

            try
            {
                if (_handler is T hander)
                {
                    disposable = func?.Invoke(Context, widget, hander);
                }
                foreach (var child in widget.GetChildren())
                {
                    Run(child, func);
                }
            }
            finally
            {
                disposable?.Dispose();
            }
        }