Пример #1
0
        public void Awake()
        {
            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Horizontal;
            MainContainer.padding             = new RectOffset(8, 8, 8, 8);

            KlyteMonoUtils.CreateUIElement(out m_previewPanel, MainContainer.transform, "previewPanel", new UnityEngine.Vector4(0, 0, 0, 300));
            m_previewPanel.autoLayout    = true;
            m_previewPanel.disabledColor = Color.black;

            KlyteMonoUtils.CreateUIElement(out UIPanel subPreviewPanel, m_previewPanel.transform, "previewSubPanel", new UnityEngine.Vector4(0, 0, MainContainer.width - 66, m_previewPanel.height));
            subPreviewPanel.backgroundSprite = "GenericPanel";
            subPreviewPanel.autoLayout       = true;
            subPreviewPanel.disabledColor    = Color.black;


            KlyteMonoUtils.CreateUIElement(out m_preview, subPreviewPanel.transform, "preview", new UnityEngine.Vector4(0, 0, subPreviewPanel.width, subPreviewPanel.height));
            KlyteMonoUtils.CreateElement(out m_previewRenderer, MainContainer.transform);
            m_previewRenderer.Size     = m_preview.size * 2f;
            m_preview.texture          = m_previewRenderer.Texture;
            m_preview.eventMouseWheel += ChangeViewZoom;
            m_preview.eventMouseMove  += OnMouseMove;
            m_previewRenderer.Zoom     = TargetZoom;
            m_preview.disabledColor    = Color.black;

            KlyteMonoUtils.CreateUIElement(out UIPanel overrideSpriteContainer, MainContainer.transform, "overrideSpriteContainer", new UnityEngine.Vector4(0, 0, MainContainer.width - 66, 300));
            overrideSpriteContainer.autoLayout          = true;
            overrideSpriteContainer.autoLayoutDirection = LayoutDirection.Horizontal;

            KlyteMonoUtils.CreateUIElement(out UIPanel overrideSpriteSubContainer, overrideSpriteContainer.transform, "overrideSpriteSubContainer", new UnityEngine.Vector4(0, 0, overrideSpriteContainer.width, overrideSpriteContainer.height));
            overrideSpriteSubContainer.backgroundSprite    = KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_SquareIcon, true);
            overrideSpriteSubContainer.autoLayout          = true;
            overrideSpriteSubContainer.autoLayoutDirection = LayoutDirection.Horizontal;

            OverrideSprite      = overrideSpriteSubContainer.AddUIComponent <UISprite>();
            OverrideSprite.size = overrideSpriteContainer.size;
            overrideSpriteSubContainer.isVisible = false;


            KlyteMonoUtils.CreateUIElement(out m_previewControls, MainContainer.transform, "controls", new UnityEngine.Vector4(0, 0, 50, 300));
            m_previewControls.padding             = new RectOffset(5, 5, 5, 5);
            m_previewControls.autoLayout          = true;
            m_previewControls.autoLayoutDirection = LayoutDirection.Vertical;


            KlyteMonoUtils.InitCircledButton(m_previewControls, out m_lockToSelection, CommonsSpriteNames.K45_Unlock, (x, y) => ToggleLock(), "K45_WTS_LOCK_UNLOCK_TO_CURRENT_ITEM");
            m_lockToSelection.focusedBgSprite = null;
            m_viewLocked = true;
            ToggleLock();

            KlyteMonoUtils.InitCircledButton(m_previewControls, out UIButton resetView, CommonsSpriteNames.K45_Reload, (x, y) => ResetCamera(), "K45_WTS_RESET_VIEW");

            UIHelperExtension.AddSpace(m_previewControls, 10);

            KlyteMonoUtils.InitCircledButton(m_previewControls, out UIButton useCurrentText, CommonsSpriteNames.K45_FontIcon, (x, y) => m_overrideText = null, "K45_WTS_USE_CURRENT_TEXT");
            KlyteMonoUtils.InitCircledButtonText(m_previewControls, out UIButton use1lText, "x1", (x, y) => m_overrideText     = "1", Locale.Get("K45_WTS_USE_1LENGHT_TEXT"));
            KlyteMonoUtils.InitCircledButtonText(m_previewControls, out UIButton use10lText, "x10", (x, y) => m_overrideText   = "Á" + new string('X', 8) + "j", Locale.Get("K45_WTS_USE_10LENGHT_TEXT"));
            KlyteMonoUtils.InitCircledButtonText(m_previewControls, out UIButton use50lText, "x50", (x, y) => m_overrideText   = "Á" + new string('L', 48) + "j", Locale.Get("K45_WTS_USE_50LENGHT_TEXT"));
            KlyteMonoUtils.InitCircledButtonText(m_previewControls, out UIButton use100lText, "x200", (x, y) => m_overrideText = "Á" + new string('C', 198) + "j", Locale.Get("K45_WTS_USE_200LENGHT_TEXT"));

            WTSPropLayoutEditor.Instance.CurrentTabChanged += (x) => ResetCamera();
        }