/*
         *              public apis
         */

        /**
         *              show information view from url.
         *  scrollView should have component which implement IUUebViewEventHandler for receiving events.
         */
        public static void Info_Show(GameObject scrollView, string url, string viewName = ConstSettings.ROOTVIEW_NAME)
        {
            var eventReceiverCandidate = scrollView.GetComponents <Component>().Where(component => component is IUUebViewEventHandler).FirstOrDefault();

            if (eventReceiverCandidate == null)
            {
                throw new Exception("information scroll view should have IUUebViewEventHandler implemented component.");
            }

            var content = scrollView.GetComponentsInChildren <RectTransform>().Where(t => t.gameObject.name == "Content").FirstOrDefault();

            if (content == null)
            {
                throw new Exception("information scroll view should have 'Content' GameObject like uGUI default ScrollView.");
            }

            var viewSize = scrollView.GetComponent <RectTransform>().sizeDelta;


            ResourceLoader.MyHttpRequestHeaderDelegate httpReqHeaderDel = (p1, p2, p3, p4) => {
                return(autoya.httpRequestHeaderDelegate(p1, p2, p3, p4));
            };

            ResourceLoader.MyHttpResponseHandlingDelegate httpResponseHandleDel = (p1, p2, p3, p4, p5, p6, p7) => {
                Action <string, int, string, AutoyaStatus> p8 = (q1, q2, q3, q4) => {
                    p7(q1, q2, q3);
                };
                autoya.httpResponseHandlingDelegate(p1, p2, p3, p4, p5, p6, p8);
            };

            var view = UUebViewComponent.GenerateSingleViewFromUrl(scrollView, url, viewSize, httpReqHeaderDel, httpResponseHandleDel, viewName);

            view.transform.SetParent(content.gameObject.transform, false);
        }
Exemple #2
0
        public static GameObject GenerateSingleViewFromHTML(
            GameObject eventReceiverScrollViewGameObj,
            string source,
            Vector2 viewRect,
            ResourceLoader.MyHttpRequestHeaderDelegate requestHeader = null,
            ResourceLoader.MyHttpResponseHandlingDelegate httpResponseHandlingDelegate = null,
            string viewName = ConstSettings.ROOTVIEW_NAME,
            Action <List <ParseError> > onParseFailed = null,
            IPluggable plugin = null
            )
        {
            var viewObj = new GameObject("UUebView");

            viewObj.AddComponent <RectTransform>();
            viewObj.name = viewName;

            // viewObjにUUebViewComponentを追加し、UUebViewComponentにコアを追加する。
            // viewObjのUUebViewComponentはuuebViewCoreインスタンスを持っているので、そのコアに外部からさらにイベントを追加することができる。
            var uuebView     = viewObj.AddComponent <UUebViewComponent>();
            var uuebViewCore = new UUebViewCore(uuebView, plugin, requestHeader, httpResponseHandlingDelegate, onParseFailed);

            uuebView.SetCore(uuebViewCore);
            uuebViewCore.LoadHtml(source, viewRect, 0f, eventReceiverScrollViewGameObj);

            return(viewObj);
        }
        public static GameObject GenerateSingleViewFromUrl(
            GameObject eventReceiverGameObj,
            string url,
            Vector2 viewRect,
            ResourceLoader.MyHttpRequestHeaderDelegate requestHeader = null,
            ResourceLoader.MyHttpResponseHandlingDelegate httpResponseHandlingDelegate = null,
            string viewName = ConstSettings.ROOTVIEW_NAME
            )
        {
            var viewObj = new GameObject("UUebView");

            viewObj.AddComponent <RectTransform>();
            viewObj.name = viewName;

            var uuebView     = viewObj.AddComponent <UUebViewComponent>();
            var uuebViewCore = new UUebViewCore(uuebView, requestHeader, httpResponseHandlingDelegate);

            uuebView.SetCore(uuebViewCore);
            uuebViewCore.DownloadHtml(url, viewRect, eventReceiverGameObj);

            return(viewObj);
        }
Exemple #4
0
        public UUebViewCore(IUUebView uuebView, IPluggable plugin = null, ResourceLoader.MyHttpRequestHeaderDelegate requestHeader = null, ResourceLoader.MyHttpResponseHandlingDelegate httpResponseHandlingDelegate = null, Action <List <ParseError> > onParseFailed = null)
        {
            if (plugin == null)
            {
                plugin = new DefaultBehaviour();
            }

            this.view = uuebView;

            resLoader = new ResourceLoader(this.LoadParallel, requestHeader, httpResponseHandlingDelegate);
            this.view.AddChild(resLoader.cacheBox.transform);

            layoutMachine      = new LayoutMachine(resLoader, plugin);
            materializeMachine = new MaterializeMachine(resLoader, plugin);

            if (onParseFailed != null)
            {
                this.onParseFailed = onParseFailed;
            }
            else
            {
                this.onParseFailed = errors =>
                {
                    Debug.LogError("parse errors:" + errors.Count);
                    foreach (var error in errors)
                    {
                        Debug.LogError("code:" + error.code + " reason:" + error.reason);
                    }
                };
            }
        }