Exemplo n.º 1
0
        protected override ReactScript GetScript()
        {
            var res = ReactScript.Resource("ReactUnity/editor/inspector/index");

            res.UseDevServer = false;
            return(res);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        protected override ReactScript GetScript()
        {
            var res = ReactScript.Resource("ReactUnity/editor/quick-start/index");

#if REACT_UNITY_DEVELOPER
            res.DevServer    = "http://localhost:4200";
            res.UseDevServer = DevServerEnabled;
#endif
            return(res);
        }
Exemplo n.º 4
0
        protected override ReactScript GetScript()
        {
            var res = ReactScript.Resource("ReactUnity/editor/style-editor/index");

#if REACT_UNITY_DEVELOPER
            res.DevServer    = "http://localhost:4000";
            res.UseDevServer = false;
#endif
            return(res);
        }
Exemplo n.º 5
0
 public ReactUnityElement(ReactScript script, GlobalRecord globals, bool autorun = true)
 {
     Script  = script;
     Globals = globals;
     AddToClassList("react-unity__host");
     if (autorun)
     {
         Run();
     }
 }
Exemplo n.º 6
0
        public void OnAppend()
        {
            var src = new ReactScript();

            src.ScriptSource = ScriptSource.Url;
            src.SourcePath   = document.origin + this.src;

            src.GetScript((sc) =>
            {
                MainThreadDispatcher.OnUpdate(() => document.execute(sc));
            }, out var result, false, true);
        }
Exemplo n.º 7
0
        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();
                    }
                }
            });
        }
Exemplo n.º 8
0
        public void send(object o)
        {
            var args = o as Jint.Native.Object.ObjectInstance;

            options = extractOptions(args);
            url     = new Uri(origin + options["url"]);

            req           = UnityWebRequest.Get(url);
            requestHandle = new DisposableHandle(context.Dispatcher, context.Dispatcher.StartDeferred(
                                                     ReactScript.WatchWebRequest(req, responseCallback, errorCallback)));

            // TODO: implement methods, headers and other options

            //req.Method = options["method"];

            // add custom headers
            //if (headers.Count != 0)
            //{
            //    foreach (string key in headers.Keys)
            //    {
            //        if (headers[key] == null)
            //            continue;

            //        switch (key.ToLower())
            //        {
            //            // in silverlight 3, these are set by the web browser that hosts the Silverlight application.
            //            // http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest%28v=vs.95%29.aspx
            //            case "connection":
            //            case "content-length":
            //            case "expect":
            //            case "if-modified-since":
            //            case "referer":
            //            case "transfer-encoding":
            //            case "user-agent":
            //                break;

            //            // in silverlight this isn't supported, can not find reference to why not
            //            case "range":
            //                break;

            //            // in .NET Framework 3.5 and below, these are set by the system.
            //            // http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest%28v=VS.90%29.aspx
            //            case "date":
            //            case "host":
            //                break;

            //            case "accept":
            //                req.Accept = (string)headers[key];
            //                break;

            //            case "content-type":
            //                req.ContentType = headers[key];
            //                break;
            //            default:
            //                req.Headers[key] = (string)headers[key];
            //                break;
            //        }
            //    }
            //}

            //req.ContentLength = 0;
            //req.ContentType = options["mimeType"];
        }