示例#1
0
        void Refresh()
        {
            if (string.IsNullOrEmpty(Key))
            {
                return;
            }
            if (CustomProjectSetting.Instance == null)
            {
                return;
            }

            LanguageManagerBase langManager = LanguageManagerBase.Instance;

            if (langManager == null)
            {
                return;
            }
            if (!langManager.IsInit)
            {
                return;
            }
            if (currentLanguage == langManager.CurrentLanguage)
            {
                return;
            }

            TextArea2D text = CachedTextArea;

            if (text != null)
            {
                text.text = langManager.LocalizeText(key);
            }
            currentLanguage = langManager.CurrentLanguage;
        }
	/// <summary>
	/// 初期化。スクリプトから動的に生成する場合に
	/// </summary>
	/// <param name="engine">ADVエンジン</param>
	public void InitOnCreate(AdvEngine engine, TextArea2D text, TextArea2D nameText, GameObject rootChildren, Node2D transrateMessageWindowRoot)
	{
		this.engine = engine;
		this.text = text;
		this.nameText = nameText;
		this.rootChildren = rootChildren;
		this.transrateMessageWindowRoot = transrateMessageWindowRoot;
	}
        public override void DrawProperties()
        {
            TextArea2D obj = target as TextArea2D;

            //テキスト
            UtageEditorToolKit.BeginGroup("Text");
            string text = EditorGUILayout.TextArea(obj.text, GUILayout.Height(60f));

            if (text != obj.text)
            {
                Undo.RecordObject(obj, "Text Change");
                obj.text = text;
                EditorUtility.SetDirty(target);
            }


            UtageEditorToolKit.PropertyField(serializedObject, "lengthOfView", "Length");
            UtageEditorToolKit.PropertyField(serializedObject, "type", "Type");
            switch (obj.Type)
            {
            case TextArea2D.ViewType.Outline:
            case TextArea2D.ViewType.Shadow:
                UtageEditorToolKit.PropertyField(serializedObject, "colorEffect", "ColorEffect");
                break;

            case TextArea2D.ViewType.Default:
            default:
                break;
            }
            UtageEditorToolKit.EndGroup();


            UtageEditorToolKit.BeginGroup("Font");
            UtageEditorToolKit.PropertyField(serializedObject, "font", "Prefab");
            UtageEditorToolKit.PropertyField(serializedObject, "size", "Size");
            UtageEditorToolKit.PropertyField(serializedObject, "pixcelsToUnits", "Pixcels To Units");
            UtageEditorToolKit.EndGroup();

            UtageEditorToolKit.BeginGroup("Clip");
            UtageEditorToolKit.PropertyField(serializedObject, "layoutType", "Layout");
            UtageEditorToolKit.PropertyField(serializedObject, "maxWidth", "Width (px)");
            UtageEditorToolKit.PropertyField(serializedObject, "maxHeight", "Height (px)");
            UtageEditorToolKit.EndGroup();

            UtageEditorToolKit.BeginGroup("Style");
            UtageEditorToolKit.PropertyField(serializedObject, "isKerning", "Kerning");
            UtageEditorToolKit.PropertyField(serializedObject, "space", "Space (px)");
            UtageEditorToolKit.PropertyField(serializedObject, "letterSpace", "Letter Space (px)");
            UtageEditorToolKit.PropertyField(serializedObject, "lineSpace", "Line Space (px)");
            UtageEditorToolKit.EndGroup();

            UtageEditorToolKit.BeginGroup("WordWrap");
            UtageEditorToolKit.PropertyField(serializedObject, "wordWrap", "Type");
            UtageEditorToolKit.EndGroup();

            UtageEditorToolKit.BeginGroup("Debug");
            UtageEditorToolKit.PropertyField(serializedObject, "isDebugMode", "");
            UtageEditorToolKit.EndGroup();

            base.DrawProperties();
        }
示例#4
0
        void CreateAdvEngile()
        {
            GameObject go     = new GameObject("AdvEngine");
            AdvEngine  engine = go.AddComponent <AdvEngine>();

            //レイヤーマネージャー
            AdvLayerManager layerManager       = UtageToolKit.AddChildGameObjectComponent <AdvLayerManager>(engine.transform, "LayerManager");
            Node2D          node2dLayerManager = layerManager.GetComponent <Node2D>();

            node2dLayerManager.SortKey = "LayerManager";

            //トランジションマネージャー
            AdvTransitionManager transitionManager = UtageToolKit.AddChildGameObjectComponent <AdvTransitionManager>(engine.transform, "TransitionManager");

            transitionManager.GetComponent <Node2D>().SortKey = "Transition";
            Sprite2D transtionBg = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(transitionManager.transform, "Bg");

            transtionBg.Sprite   = transitionFadeBg;
            transtionBg.SizeType = Sprite2D.SpriteSizeType.StrechBoth;

            //UIマネージャー
            AdvUiManager uiManager = UtageToolKit.AddChildGameObjectComponent <AdvUiManager>(engine.transform, "UI");

            //インプットマネージャー
            AdvLegacyInputManager input = UtageToolKit.AddChildGameObjectComponent <AdvLegacyInputManager>(uiManager.transform, "InputManager");

            input.InitOnCreate(engine, 1.0f / 100 * gameScreenWidth, 1.0f / 100 * gameScreenHeight);
            input.GetComponent <Node2D>().SortKey = "InputManager";

            //メッセージウィンドウ
            float fontSize               = 30;
            float windowWidth            = msgWindowSprite.rect.width;
            float windowHeight           = msgWindowSprite.rect.height;
            AdvUiMessageWindow msgWindow = UtageToolKit.AddChildGameObjectComponent <AdvUiMessageWindow>(uiManager.transform, "MessageWindow");

            msgWindow.GetComponent <Node2D>().SortKey = "MessageWindow";
            GameObject windowRootChildren = UtageToolKit.AddChildGameObject(msgWindow.transform, "RootChildren");
            TextArea2D messageText        = UtageToolKit.AddChildGameObjectComponent <TextArea2D>(windowRootChildren.transform, "MessageText");

            messageText.Type       = TextArea2D.ViewType.Outline;
            messageText.Font       = font;
            messageText.text       = "Message";
            messageText.Size       = fontSize;
            messageText.LayoutType = TextArea2D.Layout.TopLeft;
            messageText.MaxWidth   = (int)(windowWidth - fontSize * 4);
            messageText.MaxHeight  = (int)(windowHeight - (fontSize * 2 + 50));
            messageText.transform.localPosition = new Vector3(-(float)messageText.MaxWidth / 2 / 100, (windowHeight / 2 - (fontSize + 40)) / 100, 0);
            messageText.LetterSpace             = 2;
            messageText.LineSpace         = 8;
            messageText.WordWrapType      = TextArea2D.WordWrap.Default | TextArea2D.WordWrap.JapaneseKinsoku;
            messageText.LocalOrderInLayer = 10;

            //名前表示
            TextArea2D nameText = UtageToolKit.AddChildGameObjectComponent <TextArea2D>(windowRootChildren.transform, "NameText");

            nameText.Type       = TextArea2D.ViewType.Outline;
            nameText.Font       = font;
            nameText.text       = "Name";
            nameText.Size       = 30;
            nameText.LayoutType = TextArea2D.Layout.TopLeft;
            nameText.transform.localPosition = new Vector3(-(float)messageText.MaxWidth / 2 / 100, (windowHeight / 2 - 25) / 100, 0);
            nameText.LocalOrderInLayer       = 10;

            //閉じるボタン
            if (isEnableCloseButton)
            {
                LegacyUiButton closeButton   = UtageToolKit.AddChildGameObjectComponent <LegacyUiButton>(windowRootChildren.transform, "CloseButton");
                Sprite2D       closeButtonBg = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(closeButton.transform, "Bg");
                closeButtonBg.Sprite = closeButtonSprite;
                closeButton.transform.localPosition = new Vector3(((windowWidth - closeButtonSprite.rect.width) / 2 - 10) / 100, ((windowHeight - closeButtonSprite.rect.height) / 2 - 5) / 100, -0.01f);
                closeButton.Target       = msgWindow.gameObject;
                closeButton.FunctionName = "OnTapCloseWindow";
                closeButton.Se           = clickSe;
            }

            //メッセージウィンドウ背景
            Node2D   windowBgRoot = UtageToolKit.AddChildGameObjectComponent <Node2D>(windowRootChildren.transform, "WindowRoot");
            Sprite2D windowBg     = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(windowBgRoot.transform, "Bg");

            windowBg.Sprite = msgWindowSprite;

            msgWindow.InitOnCreate(engine, messageText, nameText, windowRootChildren, windowBgRoot);
            msgWindow.transform.localPosition = new Vector3(0, (-gameScreenHeight + windowHeight) / 2 / 100, 0);

            //選択肢
            AdvUiSelectionManager selection = UtageToolKit.AddChildGameObjectComponent <AdvUiSelectionManager>(uiManager.transform, "Selection");

            selection.InitOnCreate(engine, selectionItemPrefab);
            selection.GetComponent <Node2D>().SortKey = "Selection";
            selection.ListView.ClipWidthPx            = Mathf.Max(gameScreenWidth / 2, gameScreenWidth - 100);
            selection.ListView.ClipHeightPx           = Mathf.Max(gameScreenHeight / 2, gameScreenHeight - 100);
            selection.ListView.Type = LegacyUiListView.LitViewType.Vertical;

            //バックログ
            AdvUiBacklogManager backLogManger = null;

            if (isEnableBackLog)
            {
                LegacyUiButton openButton = UtageToolKit.AddChildGameObjectComponent <LegacyUiButton>(windowRootChildren.transform, "BackLogButton");
                UtageToolKit.AddChildGameObjectComponent <Sprite2D>(openButton.transform, "Bg").Sprite = backLogButtonSprite;
                TextArea2D text = UtageToolKit.AddChildGameObjectComponent <TextArea2D>(openButton.transform, "Text");
                text.Font = font;
                text.text = "Log";
                text.LocalOrderInLayer             = 10;
                openButton.transform.localPosition = new Vector3(((windowWidth - backLogButtonSprite.rect.width) / 2 - closeButtonSprite.rect.width - 20) / 100, ((windowHeight - closeButtonSprite.rect.height) / 2 - 5) / 100, -0.01f);
                openButton.Target       = msgWindow.gameObject;
                openButton.FunctionName = "OnTapBackLog";
                openButton.Se           = clickSe;

                backLogManger = UtageToolKit.AddChildGameObjectComponent <AdvUiBacklogManager>(uiManager.transform, "BackLog");
                backLogManger.InitOnCreate(engine, backLogItemPrefab);
                backLogManger.GetComponent <Node2D>().SortKey = "BackLog";
                backLogManger.ListView.ClipWidthPx            = Mathf.Max(gameScreenWidth / 2, gameScreenWidth - 100);
                backLogManger.ListView.ClipHeightPx           = Mathf.Max(gameScreenHeight / 2, gameScreenHeight - 100);
                backLogManger.ListView.Type = LegacyUiListView.LitViewType.Vertical;
                backLogManger.ListView.IsRepositionReverse = true;

                Sprite2D filter = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(backLogManger.transform, "filter");
                filter.Sprite     = backLogFilterSprite;
                filter.SizeType   = Sprite2D.SpriteSizeType.StrechBoth;
                filter.LocalColor = Color.black;
                filter.LocalAlpha = 0.5f;

                float    arrowY   = (float)backLogManger.ListView.ClipHeightPx / 100 / 2;
                Sprite2D minArrow = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(backLogManger.transform, "MinArrow");
                minArrow.Sprite                  = backLogScrollUpArrow;
                minArrow.LocalOrderInLayer       = 30;
                minArrow.transform.localPosition = new Vector3(0, arrowY);
                backLogManger.ListView.MinArrow  = minArrow.gameObject;
                Sprite2D maxArrow = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(backLogManger.transform, "MaxArrow");
                maxArrow.Sprite                     = backLogScrollUpArrow;
                maxArrow.LocalOrderInLayer          = 30;
                maxArrow.transform.localPosition    = new Vector3(0, -arrowY);
                maxArrow.transform.localEulerAngles = new Vector3(0, 0, 180);
                backLogManger.ListView.MaxArrow     = maxArrow.gameObject;

                LegacyUiButton closeButton   = UtageToolKit.AddChildGameObjectComponent <LegacyUiButton>(backLogManger.transform, "CloseButton");
                Sprite2D       closeButtonBg = UtageToolKit.AddChildGameObjectComponent <Sprite2D>(closeButton.transform, "Bg");
                closeButtonBg.Sprite = backLogCloseButtonSprite;
                closeButton.transform.localPosition = new Vector3((-1.0f * (gameScreenWidth - backLogCloseButtonSprite.rect.width) / 2 + 5) / 100, ((gameScreenHeight - backLogCloseButtonSprite.rect.height) / 2 - 5) / 100, -0.01f);
                closeButton.Target       = backLogManger.gameObject;
                closeButton.FunctionName = "OnTapBack";
                closeButton.Se           = clickSe;
                TextArea2D textClose = UtageToolKit.AddChildGameObjectComponent <TextArea2D>(closeButton.transform, "Text");
                textClose.Font = font;
                textClose.text = "";
                textClose.LocalOrderInLayer = 10;
                LegacyLocalize localize = textClose.gameObject.AddComponent <LegacyLocalize>();
                localize.Key = SystemText.Back.ToString();
            }


            engine.InitOnCreate(layerManager, transitionManager, uiManager);

            AdvLegacyUiManager legacyUiManager = uiManager as AdvLegacyUiManager;

            if (legacyUiManager != null)
            {
                legacyUiManager.InitOnCreate(engine, msgWindow, selection, backLogManger);
            }
            Selection.activeGameObject = go;
            Undo.RegisterCreatedObjectUndo(go, "CreateAdvEngile");
        }