예제 #1
0
        private void OnEnable()
        {
            this.titleContent = new GUIContent("对话预览");

            mTitleStyle.fontSize         = 18;
            mTitleStyle.alignment        = TextAnchor.UpperLeft;
            mTitleStyle.padding          = new RectOffset(5, 5, 5, 5);
            mTitleStyle.normal.textColor = TinaX.Core.XEditorStyleDefine.Color_Text_Normal;


            mContentStyle.fontSize         = 16;
            mContentStyle.alignment        = TextAnchor.MiddleLeft;
            mContentStyle.padding          = new RectOffset(5, 5, 5, 5);
            mContentStyle.normal.textColor = TinaX.Core.XEditorStyleDefine.Color_Text_Normal;

            //初始化播放器
            mPlayer          = new DialoguePlayer();
            mPlayer.OnChoose = (data) =>
            {
                mTitle   = data.GetTitle();
                mContent = "";
                mSpeaker = data.GetSpeaker();
                //按钮列表
                var           chooseList = data.GetChooseList();
                List <Button> btns       = new List <Button>();
                foreach (var item in chooseList)
                {
                    btns.Add(new Button()
                    {
                        Title    = item,
                        callback = () =>
                        {
                            mPlayer.NextWithString(item);
                        }
                    });
                }
                mButtonGroup = btns.ToArray();

                mCurStatus = GUIStatus.choose;
            };
            mPlayer.OnContent = (data) =>
            {
                mTitle   = "";
                mContent = data.GetContent();
                mSpeaker = data.GetSpeaker();

                mCurStatus = GUIStatus.content;
            };
            mPlayer.OnFinish = (data) =>
            {
                mCurStatus = GUIStatus.finish;
                mContent   = data;
            };
        }