public UnityComponent createText(string text, HostComponent host) { var cmp = ComponentCreators["text"]("_text", text, host.Context); cmp.IsPseudoElement = true; return(cmp); }
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(); } } }); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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(); } } }); }
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(); } } }); }
public static void appendChildToContainer(HostComponent parent, UnityComponent child) { child.SetParent(parent); parent.ScheduleLayout(); }
public static UnityComponent createText(string text, HostComponent host) { return(ComponentCreators["text"]("text", text, host.Context)); }