コード例 #1
0
		/// <summary>
		/// 初期化。スクリプトから動的に生成する場合に
		/// </summary>
		/// <param name="engine">ADVエンジン</param>
		public void InitOnCreate(AdvEngine engine, AdvUiMessageWindow messageWindow, AdvUiSelectionManager selection, AdvUiBacklogManager backLog)
		{
			this.engine = engine;
			this.messageWindow = messageWindow;
			this.selection = selection;
			this.backLog = backLog;
		}
コード例 #2
0
 /// <summary>
 /// 初期化。スクリプトから動的に生成する場合に
 /// </summary>
 /// <param name="engine">ADVエンジン</param>
 public void InitOnCreate(AdvEngine engine, AdvUiMessageWindow messageWindow, AdvUiSelectionManager selection, AdvUiBacklogManager backLog)
 {
     this.engine        = engine;
     this.messageWindow = messageWindow;
     this.selection     = selection;
     this.backLog       = backLog;
 }
コード例 #3
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");
        }