Beispiel #1
0
        private static CanvasObject CanvasObjectInit(CanvasType type, string name)
        {
            var canvasObject = new CanvasObject();

            canvasObject.Init(type, name);
            return(canvasObject);
        }
Beispiel #2
0
        //キャンバス生成
        private static CanvasObject CanvasObjectInit(Canvas canvas)
        {
            var canvasObject = new CanvasObject();

            canvasObject.Init(canvas);
            return(canvasObject);
        }
Beispiel #3
0
        public static CanvasObject CreateCanvas(Canvas canvas)
        {
            var canvasObject = new CanvasObject();

            canvasObject.Init(canvas);
            return(canvasObject);
        }
Beispiel #4
0
        public CanvasStock(EventSystemObject eso, CanvasObject dc, CanvasObject sc, List <CanvasObject> oc)
        {
            _eventSystem   = eso;
            _dynamicCanvas = dc;
            _staticCanvas  = sc;

            _otherCanvas = oc;
        }
Beispiel #5
0
        public CanvasStock(EventSystemObject eso, CanvasObject dc, CanvasObject sc, int capacity)
        {
            _eventSystem   = eso;
            _dynamicCanvas = dc;
            _staticCanvas  = sc;

            _otherCanvas = new List <CanvasObject>(capacity);
        }
Beispiel #6
0
        //Canvasの代入
        public void Init(Canvas canvas)
        {
            CanvasObject co = default;

            try
            {
                co = new CanvasObject
                {
                    Canvas           = canvas,
                    CanvasScaler     = canvas.gameObject.GetComponent <CanvasScaler>(),
                    GraphicRaycaster = canvas.gameObject.GetComponent <GraphicRaycaster>()
                };
            }
            catch
            {
                this = default;
            }
            this = co;
        }
Beispiel #7
0
        public static CanvasObject CreateCanvas(CanvasType type = CanvasType.Dynamic, string name = "")
        {
            var go = new GameObject();

            go.transform.name = name + "Canvas";
            if (type == CanvasType.Static)
            {
                go.isStatic = true;
            }
            go.layer = LayerMask.NameToLayer("UI");
            var c = go.AddComponent <Canvas>();

            c.renderMode = RenderMode.ScreenSpaceOverlay;
            var cs = go.AddComponent <CanvasScaler>();
            var gr = go.AddComponent <GraphicRaycaster>();
            var co = new CanvasObject(c, cs, gr);

            return(co);
        }
Beispiel #8
0
 //OtherCanvas追加用
 public void AddCanvas(CanvasObject canvasObject)
 {
     _otherCanvas.Add(canvasObject);
 }
Beispiel #9
0
        private void Awake()
        {
            DontDestroyOnLoad(gameObject);
            //名前の設定
            gameObject.name = "UI_Kit";

            //Creator初期化
            Creator.Init();

            var go = GameObject.Find("EventSystem");
            var es = go != null?go.GetComponent <EventSystem>() : null;

            var eventSystemObject = new EventSystemObject(es, null);

            //EventStyleがないなら
            if (eventSystemObject.EventSystem == null)
            {
                //EventSystem初期化
                eventSystemObject.Init();
            }
            else
            {
                eventSystemObject.StandaloneInputModule = go.GetComponent <StandaloneInputModule>();
            }

            //Canvas
            CanvasObject useDynamicCanvas = default;
            CanvasObject useStaticCanvas  = default;
            //オリジナルCanvas
            var useOtherCanvas = new List <CanvasObject>(otherCanvas.Count);

            //Canvas初期化
            //作成済みのDynamicCanvasを使う場合
            if (useCreatedDynamicCanvas && (setOrCreateCanvas == SetOrCreateCanvasType.Dynamic || setOrCreateCanvas == SetOrCreateCanvasType.Both))
            {
                useDynamicCanvas = CanvasObjectInit(this.dynamicCanvas);
            }
            else if (setOrCreateCanvas == SetOrCreateCanvasType.Dynamic || setOrCreateCanvas == SetOrCreateCanvasType.Both)
            {
                useDynamicCanvas = CanvasObjectInit(CanvasType.Dynamic, "Dynamic");
            }

            //作成済みのStaticCanvasを使う場合
            if (useCreatedStaticCanvas && (setOrCreateCanvas == SetOrCreateCanvasType.Static || setOrCreateCanvas == SetOrCreateCanvasType.Both))
            {
                useStaticCanvas = CanvasObjectInit(this.staticCanvas);
            }
            else if (setOrCreateCanvas == SetOrCreateCanvasType.Static || setOrCreateCanvas == SetOrCreateCanvasType.Both)
            {
                useStaticCanvas = CanvasObjectInit(CanvasType.Static, "Static");
            }

            //オリジナルCanvas初期化
            //作成済みのOtherCanvasを使う場合
            if (useCreatedOtherCanvas)
            {
                foreach (var _ in otherCanvas.Select((value, index) => new { Value = value, Index = index }))
                {
                    useOtherCanvas[_.Index] = CanvasObjectInit(_.Value);
                }
            }
            else
            {
                foreach (var _ in otherCanvas.Select((value, index) => new { Value = value, Index = index }))
                {
                    useOtherCanvas[_.Index] = CanvasObjectInit(CanvasType.Dynamic, _.Value.transform.name);
                }
            }
            //Stockに代入
            var canvasStock = new CanvasStock(eventSystemObject, useDynamicCanvas, useStaticCanvas, useOtherCanvas);

            Stock = canvasStock;
        }