예제 #1
0
        public async Task Open(bool notify = true)
        {
            if (_firstActivation)
            {
                ParserParams = await _bsmlDecorator.ParseFromResourceAsync(_resourceName, gameObject, this);

                gameObject.SetActive(false);
                _firstActivation = false;

                foreach (var obj in ParserParams.GetObjectsWithTag("canvas"))
                {
                    var newParent = obj.transform.parent.CreateGameObject("CanvasContainer");
                    newParent.AddComponent <RectTransform>();
                    newParent.AddComponent <VerticalLayoutGroup>();
                    newParent.AddComponent <ContentSizeFitter>().horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
                    newParent.AddComponent <LayoutElement>();

                    newParent.AddComponent <Canvas>();
                    var canvasScaler = newParent.AddComponent <CanvasScaler>();
                    canvasScaler.referencePixelsPerUnit = 10;
                    canvasScaler.scaleFactor            = 3.44f;

                    newParent.AddComponent <CurvedCanvasSettings>();
                    UIHelpers.AddVrRaycaster(newParent, _raycasterWithCache);

                    obj.transform.SetParent(newParent.transform, false);
                }

                await Init();
            }

            gameObject.SetActive(true);
            if (notify)
            {
                DidOpen();
            }
        }