コード例 #1
0
ファイル: ReactUnityAPI.cs プロジェクト: tuanminh3395/core
        public UnityComponent createText(string text, HostComponent host)
        {
            var cmp = ComponentCreators["text"]("_text", text, host.Context);

            cmp.IsPseudoElement = true;
            return(cmp);
        }
コード例 #2
0
ファイル: UnityUGUIContext.cs プロジェクト: tuanminh3395/core
        public UnityUGUIContext(RectTransform hostElement, Jint.Engine engine, StringObjectDictionary assets, ReactScript script, bool isDevServer)
        {
            Engine      = engine;
            Globals     = assets;
            Script      = script;
            IsDevServer = isDevServer;

            Parser    = new StylesheetParser(true, true, true, true, true);
            StyleTree = new StyleTree(Parser);

            Host           = new HostComponent(hostElement, this);
            Host.Tag       = "_root";
            RootLayoutNode = Host.Layout;

            InsertStyle(ResourcesHelper.UseragentStylesheet?.text, -1);
            Host.ResolveStyle(true);

            MainThreadDispatcher.AddCallOnLateUpdate(() =>
            {
                if (Scheduled)
                {
                    RootLayoutNode.CalculateLayout();
                    Scheduled = false;

                    for (int i = 0; i < ScheduledCallbacks.Count; i++)
                    {
                        ScheduledCallbacks[i]?.Invoke();
                    }
                }
            });
        }
コード例 #3
0
        public UGUIContext(RectTransform hostElement, StringObjectDictionary globals, ReactScript script, IDispatcher dispatcher, IUnityScheduler scheduler, bool isDevServer, Action onRestart)
            : base(globals, script, dispatcher, scheduler, isDevServer, onRestart)
        {
            Host           = new HostComponent(hostElement, this);
            RootLayoutNode = Host.Layout;

            InsertStyle(ResourcesHelper.UseragentStylesheet?.text, -1);
            Host.ResolveStyle(true);

            Action callback = () =>
            {
                if (Scheduled)
                {
                    RootLayoutNode.CalculateLayout();
                    Scheduled = false;

                    for (int i = 0; i < ScheduledCallbacks.Count; i++)
                    {
                        ScheduledCallbacks[i]?.Invoke();
                    }
                }
            };

            dispatcher.AddCallOnLateUpdate(callback);
        }
コード例 #4
0
        public VsIdleTaskHost(System.IServiceProvider serviceProvider, Func<bool> task, TimeSpan updateDelay)
        {
            Guard.NotNull(() => serviceProvider, serviceProvider);
            Guard.NotNull(() => task, task);

            this.componentManager = (IOleComponentManager)serviceProvider.GetService(typeof(SOleComponentManager));
            this.host = new HostComponent(task, updateDelay);
        }
コード例 #5
0
        public VsIdleTaskHost(System.IServiceProvider serviceProvider, Func <bool> task, TimeSpan updateDelay)
        {
            Guard.NotNull(() => serviceProvider, serviceProvider);
            Guard.NotNull(() => task, task);

            this.componentManager = (IOleComponentManager)serviceProvider.GetService(typeof(SOleComponentManager));
            this.host             = new HostComponent(task, updateDelay);
        }
コード例 #6
0
ファイル: EditorContext.cs プロジェクト: mfandreich/core
        public EditorContext(VisualElement hostElement, GlobalRecord globals, ReactScript script, IDispatcher dispatcher, IUnityScheduler scheduler, bool isDevServer, Action onRestart = null)
            : base(globals, script, dispatcher, scheduler, isDevServer, onRestart, true)
        {
            Host = new HostComponent(hostElement, this);
            InsertStyle(EditorResourcesHelper.UseragentStylesheet?.text, -1);
            Host.ResolveStyle(true);

            hostElement.styleSheets.Add(EditorResourcesHelper.UtilityStylesheet);
        }
コード例 #7
0
ファイル: ReactUnityAPI.cs プロジェクト: tuanminh3395/core
        public UnityComponent createElement(string tag, string text, HostComponent host)
        {
            UnityComponent res = null;

            if (ComponentCreators.TryGetValue(tag, out var creator))
            {
                res = creator(tag, text, host.Context);
            }
            else
            {
                res = defaultCreator(tag, text, host.Context);
            }
            res.GameObject.name = $"<{tag}>";
            return(res);
        }
コード例 #8
0
        public static UnityComponent createElement(string tag, string text, HostComponent host)
        {
            UnityComponent res = null;

            if (ComponentCreators.TryGetValue(tag, out var creator))
            {
                res = creator(tag, text, host.Context);
            }
            else
            {
                throw new Exception($"Unknown component tag '{tag}' specified.");
            }
            res.GameObject.name = $"<{tag}>";
            return(res);
        }
コード例 #9
0
        public UGUIContext(RectTransform hostElement, GlobalRecord globals, ReactScript script, IDispatcher dispatcher, IUnityScheduler scheduler, bool isDevServer, Action onRestart)
            : base(globals, script, dispatcher, scheduler, isDevServer, onRestart)
        {
            Host           = new HostComponent(hostElement, this);
            RootLayoutNode = Host.Layout;

            InsertStyle(ResourcesHelper.UseragentStylesheet?.text, -1);
            Host.ResolveStyle(true);

            Action callback = () =>
            {
                if (LayoutScheduled)
                {
                    RootLayoutNode.CalculateLayout();
                    LayoutScheduled = false;
                }
            };

            dispatcher.OnEveryLateUpdate(callback);
        }
コード例 #10
0
        public UnityUGUIContext(RectTransform hostElement, Engine engine, StringObjectDictionary assets)
        {
            Engine         = engine;
            NamedAssets    = assets;
            Host           = new HostComponent(hostElement, this);
            RootLayoutNode = Host.Layout;

            MainThreadDispatcher.AddCallOnLateUpdate(() =>
            {
                if (Scheduled)
                {
                    RootLayoutNode.CalculateLayout();
                    Scheduled = false;

                    for (int i = 0; i < ScheduledCallbacks.Count; i++)
                    {
                        ScheduledCallbacks[i]?.Invoke();
                    }
                }
            });
        }
コード例 #11
0
ファイル: EditorContext.cs プロジェクト: gaozhou/core-1
        public EditorContext(VisualElement hostElement, StringObjectDictionary globals, ReactScript script, IDispatcher dispatcher, IUnityScheduler scheduler, bool isDevServer, ReactWindow editor, Action onRestart = null)
            : base(globals, script, dispatcher, scheduler, isDevServer, onRestart, true)
        {
            Editor = editor;
            Host   = new HostComponent(hostElement, this);
            InsertStyle(EditorResourcesHelper.UseragentStylesheet?.text, -1);
            Host.ResolveStyle(true);

            hostElement.styleSheets.Add(EditorResourcesHelper.UtilityStylesheet);

            dispatcher.AddCallOnLateUpdate(() =>
            {
                if (Scheduled)
                {
                    Scheduled = false;

                    for (int i = 0; i < ScheduledCallbacks.Count; i++)
                    {
                        ScheduledCallbacks[i]?.Invoke();
                    }
                }
            });
        }
コード例 #12
0
 public static void appendChildToContainer(HostComponent parent, UnityComponent child)
 {
     child.SetParent(parent);
     parent.ScheduleLayout();
 }
コード例 #13
0
 public static UnityComponent createText(string text, HostComponent host)
 {
     return(ComponentCreators["text"]("text", text, host.Context));
 }