コード例 #1
0
    public void Setup()
    {
        rootObj = new GameObject();
        var rectTrans = rootObj.AddComponent <RectTransform>();

        rectTrans.anchorMin = new Vector2(0, 1);
        rectTrans.anchorMax = new Vector2(0, 1);
        rectTrans.pivot     = new Vector2(0, 1);

        view = rootObj.AddComponent <UUebViewComponent>();
        core = new UUebView.UUebViewCore(view);
        view.SetCore(core);

        var canvas = GameObject.Find("Canvas/MaterializeTestPlace");

        if (canvas == null)
        {
            var prefab     = Resources.Load <GameObject>("TestPrefabs/Canvas");
            var canvasBase = GameObject.Instantiate(prefab);
            canvasBase.name = "Canvas";
            canvas          = GameObject.Find("Canvas/MaterializeTestPlace");
        }


        rootObj.transform.SetParent(canvas.transform, false);

        rectTrans.anchoredPosition = new Vector2(100 * index, 0);
        index++;

        parser = new HTMLParser(core.resLoader, core.defaultImageDownloader);
    }
コード例 #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);
        }
コード例 #3
0
    public void Setup()
    {
        executor = new GameObject("htmlParserTest").AddComponent <UUebViewComponent>();
        var core = new UUebView.UUebViewCore(executor);

        executor.SetCore(core);
        loader = new ResourceLoader(executor.Core.CoroutineExecutor);

        parser = new HTMLParser(loader);
    }
コード例 #4
0
    public void Setup()
    {
        executor = new GameObject("layoutMachineTest").AddComponent <UUebViewComponent>();
        var core = new UUebView.UUebViewCore(executor);

        executor.SetCore(core);

        loader = new ResourceLoader(executor.Core.CoroutineExecutor);
        defaultImageDownloader = new DefaultImageDownloader(executor.Core.CoroutineExecutor, loader);

        parser = new HTMLParser(loader, defaultImageDownloader);
    }
コード例 #5
0
        void Start()
        {
            /*
             *  if preset parameters exists, UUebView shows preset view on this gameObject.
             *  this feature is for testing.
             */
            if (!string.IsNullOrEmpty(presetUrl))
            {
                Debug.Log("show preset view.");
                var viewObj = this.gameObject;

                var uuebView     = viewObj.GetComponent <UUebViewComponent>();
                var uuebViewCore = new UUebViewCore(uuebView);
                uuebView.SetCore(uuebViewCore);
                uuebViewCore.DownloadHtml(presetUrl, GetComponent <RectTransform>().sizeDelta, presetEventReceiver);
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        // スクロールイベントから生成を行う ↓
        // オブジェクトプールの再考(画面外に行ったオブジェクトのプール復帰、新しい要素のプールからの取得)

        // Layer系のオブジェクト、高さが0のツリー、hiddenを無視する(この辺は上記のチョイス時に削れると良さそう。)
        public IEnumerator Materialize(GameObject root, UUebViewCore core, TagTree tree, Vector2 viewRect, float yOffset, Action onLoaded)
        {
            var viewHeight = viewRect.y;

            {
                var rootRectTrans = root.GetComponent <RectTransform>();
                this.core = core;

                // set anchor to left top.
                rootRectTrans.anchorMin = Vector2.up;
                rootRectTrans.anchorMax = Vector2.up;
                rootRectTrans.pivot     = Vector2.up;

                rootRectTrans.sizeDelta = new Vector2(tree.viewWidth, tree.viewHeight);
            }

            // 描画範囲にあるツリーのidを集める。ここから一瞬でも外れたらskip。
            var drawTreeIds = TraverseTree(tree, yOffset, viewHeight);

            // materialize root's children in parallel.
            var children = tree.GetChildren();

            var cors = new List <IEnumerator>();

            for (var i = 0; i < children.Count; i++)
            {
                var child = children[i];
                var cor   = MaterializeRecursive(child, root, drawTreeIds);
                cors.Add(cor);
            }

            // firstviewのmaterializeまでを並列で実行する
            while (true)
            {
                for (var i = 0; i < cors.Count; i++)
                {
                    var cor = cors[i];
                    if (cor == null)
                    {
                        continue;
                    }

                    var cont = cor.MoveNext();

                    if (!cont)
                    {
                        cors[i] = null;
                    }
                }

                var running = cors.Where(c => c != null).Any();

                // wait all coroutine's end.
                if (!running)
                {
                    break;
                }

                yield return(null);
            }

            onLoaded();
        }
コード例 #8
0
 public void SetCore(UUebViewCore core)
 {
     this.Core = core;
 }