コード例 #1
0
        //////////////////////////////////////////////////////////////////////////////

        #region Playmode

        internal static void OnPlayModeChanged(bool isPlaying)
        {
            CEditor.OnPlayModeChanged(isPlaying);

            if (isPlaying)
            {
                // create a runtime object to properly handle key bindings
                GameObject runtimeObj = new GameObject("Lunar Runtime Behaviour");
                runtimeObj.AddComponent <LunarRuntimeBehaviour>();
            }
        }
コード例 #2
0
ファイル: CEditor.cs プロジェクト: tonymtz/super-unity-bros
        internal static bool OpenFileExternal(string stackTrace)
        {
            CSourcePathEntry element;

            if (CUnityStackTraceParser.TryParse(stackTrace, out element))
            {
                return(CEditor.OpenFileAtLineExternal(element.sourcePath, element.lineNumber));
            }

            return(false);
        }
コード例 #3
0
        private void DrawStackLine(ref CStackTraceLine stackLine, GUIStyle style)
        {
            if (stackLine.IsClickable)
            {
                GUIStyle linkStyle = stackLine.sourcePathExists ? CSharedStyles.consoleLinkStyle : CSharedStyles.consoleLinkInnactiveStyle;
                CUIHelper.DrawUnderLine(stackLine.sourceFrame, linkStyle);

                if (stackLine.sourcePathExists && GUI.Button(stackLine.sourceFrame, GUIContent.none, GUIStyle.none))
                {
                    CEditor.OpenFileAtLineExternal(stackLine.sourcePath, stackLine.lineNumber);
                }
            }
            GUI.Label(stackLine.frame, stackLine.line, style);
        }
コード例 #4
0
 public override void AssertMessage(string message, string stackTrace)
 {
     CEditor.ShowDialog("Assertion", message + "\n" + stackTrace,
                        new CEditor.DialogButton("Ignore"),
                        new CEditor.DialogButton("Show", delegate()
     {
         CEditor.OpenFileExternal(stackTrace);
     }),
                        new CEditor.DialogButton("Stop", delegate()
     {
         if (Application.isPlaying)
         {
             Debug.DebugBreak();
         }
     })
                        );
 }
コード例 #5
0
        //////////////////////////////////////////////////////////////////////////////

        public override bool OnMouseDoubleClick(CEvent evt)
        {
            if (!string.IsNullOrEmpty(StackTrace))
            {
                if (CEditor.OpenFileExternal(StackTrace))
                {
                    return(true);
                }
            }
            else if (this.LogLevel == CLogLevel.Error || this.LogLevel == CLogLevel.Warn)
            {
                CSourcePathEntry element;
                if (CEditorStackTrace.TryParseCompilerMessage(m_value, out element))
                {
                    if (CEditor.OpenFileAtLineExternal(element.sourcePath, element.lineNumber))
                    {
                        return(true);
                    }
                }
            }

            return(base.OnMouseDoubleClick(evt));
        }
コード例 #6
0
        private void CreateUI()
        {
            this.AutoresizeMask = CViewAutoresizing.FlexibleWidth | CViewAutoresizing.FlexibleHeight;

            CToolBar toolbar = new CToolBar(this.Width);

            toolbar.Width = this.Width;

            toolbar.AddButton("Clear", delegate(CButton button)
            {
                Terminal.Clear();
            });

            // copy to clipboard
            toolbar.AddButton("Copy", delegate(CButton button)
            {
                string text = GetText();
                CEditor.CopyToClipboard(text);
            });

            // save to file
            toolbar.AddButton("Save", delegate(CButton button)
            {
                string title       = "Console log";
                string directory   = CFileUtils.DataPath;
                string defaultName = string.Format("console");
                string filename    = CEditor.SaveFilePanel(title, directory, defaultName, "log");
                if (!string.IsNullOrEmpty(filename))
                {
                    string text = GetText();
                    CFileUtils.Write(filename, text);
                }
            });

            m_infoLabel = toolbar.AddLabel("");

            toolbar.AddFlexibleSpace();

            AddSubview(toolbar);

            m_commandField       = new CTextField();
            m_commandField.Width = Width;
            AddSubview(m_commandField);
            m_commandField.AlignX(CView.AlignCenter);
            m_commandField.AlignBottom(0);
            m_commandField.AutoresizeMask = CViewAutoresizing.FlexibleTopMargin | CViewAutoresizing.FlexibleWidth;

            m_commandField.TextKeyDelegate = delegate(CTextField tf, KeyCode code, bool pressed)
            {
                if (pressed)
                {
                    switch (code)
                    {
                    case KeyCode.Return:
                    case KeyCode.KeypadEnter:
                    {
                        string commandLine = tf.Text.Trim();
                        if (commandLine.Length > 0)
                        {
                            HistoryPush(commandLine);
                            ExecCommand(commandLine);
                        }
                        tf.Text = "";
                        HistoryReset();

                        return(true);
                    }

                    case KeyCode.Tab:
                    {
                        string line = Terminal.DoAutoComplete(tf.Text, tf.CaretPos, IsDoubleTab());
                        if (line != null)
                        {
                            tf.Text = line;
                        }
                        m_lastTabTimestamp = Time.realtimeSinceStartup;
                        return(true);
                    }

                    case KeyCode.Escape:
                    {
                        tf.Text = "";
                        HistoryReset();
                        return(true);
                    }

                    case KeyCode.C:
                    {
                        if (tf.IsCtrlPressed)
                        {
                            tf.Text = "";
                            HistoryReset();
                            return(true);
                        }
                        break;
                    }

                    case KeyCode.K:
                    {
                        if (tf.IsCtrlPressed)
                        {
                            Terminal.Clear();
                            return(true);
                        }
                        break;
                    }

                    case KeyCode.DownArrow:
                    {
                        if (HistoryNext(tf))
                        {
                            return(true);
                        }

                        if (m_lastUserInput != null)
                        {
                            tf.Text = m_lastUserInput;
                            HistoryReset();
                            return(true);
                        }

                        return(true);
                    }

                    case KeyCode.UpArrow:
                    {
                        // keep user input to restore it
                        if (m_lastUserInput == null)
                        {
                            m_lastUserInput = tf.Text;
                        }

                        if (HistoryPrev(tf))
                        {
                            return(true);
                        }

                        return(true);
                    }
                    }
                }

                return(false);
            };

            m_commandField.TextChangedDelegate = delegate(CTextField field) {
                HistoryReset();
            };

            m_consoleView   = new CConsoleView(Terminal, m_commandField.Width, this.Height - (toolbar.Height + m_commandField.Height));
            m_consoleView.Y = toolbar.Bottom;
            m_consoleView.IsScrollLocked = true;
            m_consoleView.AutoresizeMask = CViewAutoresizing.FlexibleWidth | CViewAutoresizing.FlexibleHeight;
            AddSubview(m_consoleView);

            m_lastUserInput = null;
        }
コード例 #7
0
ファイル: CCommands.cs プロジェクト: tonymtz/super-unity-bros
 void Execute()
 {
     CEditor.Break();
 }