Пример #1
0
        private YxWindowCoverInfo CreateNguiCoverStyle(int layer)
        {
            var coverInfo = new YxWindowCoverInfo();
            var go        = new GameObject("NguiCover")
            {
                layer = layer
            };
            var ts = go.transform;
            var p  = YxWindowManager.Instance.GetWindowContainer(YxEUIType.Nguid);

            GameObjectUtile.ResetTransformInfo(ts, p);
            go.AddComponent <UIPanel>();
            var textureGo = new GameObject("Background");

            textureGo.layer = layer;
            GameObjectUtile.ResetTransformInfo(textureGo.transform, ts);
            var box  = textureGo.AddComponent <BoxCollider>();
            var size = box.size;

            size.z   = 2;
            box.size = size;
            var uitexture = textureGo.AddComponent <UITexture>();

            uitexture.SetAnchor(go);
            uitexture.autoResizeBoxCollider = true;
            uitexture.ResizeCollider();
            coverInfo.Panel      = go.AddComponent <NguiPanelAdapter>();
            coverInfo.Background = textureGo.AddComponent <NguiTextureAdapter>();
            return(coverInfo);
        }
Пример #2
0
        private YxWindowCoverInfo CreateUguiCoverStyle(int layer)
        {
            var coverInfo = new YxWindowCoverInfo();
            var go        = new GameObject("UguiCover")
            {
                layer = layer
            };
            var ts = go.transform;
            var p  = YxWindowManager.Instance.GetWindowContainer(YxEUIType.Ugui);

            GameObjectUtile.ResetTransformInfo(ts, p);
            var canvas = go.AddComponent <Canvas>();

            canvas.enabled         = true;
            canvas.overrideSorting = true;
            var raycaster = go.AddComponent <GraphicRaycaster>();
            //            var collider = go.AddComponent<BoxCollider>();
            var rectTs           = go.GetComponent <RectTransform>();
            var uguiPanelAdapter = go.AddComponent <UguiPanelAdapter>();

            uguiPanelAdapter.OverrideSorting = true;
            uguiPanelAdapter.IsMainPanel     = true;
            var textureGo = new GameObject("Background");

            textureGo.layer = layer;
            GameObjectUtile.ResetTransformInfo(textureGo.transform, rectTs);
            var background = textureGo.AddComponent <RawImage>();
            var color      = Color.black;

            color.a          = 0.5f;
            background.color = color;
            coverInfo.Panel  = uguiPanelAdapter;
            var textureAdapter = textureGo.AddComponent <UguiRawImageAdapter>();

            textureAdapter.SetAnchor(go, 0, 0, 0, 0);
            coverInfo.Background = textureAdapter;
            return(coverInfo);
        }