private void Awake() { UnityConsole console = GetComponent <UnityConsole>(); uiTransform = console.GetUiTransform(); if (_screenSpaceCanvas == null) { Canvas c = uiTransform.parent.GetComponent <Canvas>(); if (c.renderMode == RenderMode.ScreenSpaceOverlay) { _screenSpaceCanvas = c; } else { _screenSpaceCanvas = FindCanvas(RenderMode.ScreenSpaceOverlay); } } if (_worldSpaceCanvas == null) { Canvas c = uiTransform.parent.GetComponent <Canvas>(); if (c.renderMode == RenderMode.WorldSpace) { _worldSpaceCanvas = c; } else { _worldSpaceCanvas = FindCanvas(RenderMode.WorldSpace); } } }
public void EnqueueConsoleTextRefresh() { Proc.Enqueue(() => { UnityConsole console = GetComponent <UnityConsole>(); console.Window.ResetWindowSize(); console.RefreshText(); }); }
public void Cmd_Clear(Command.Exec e) { UnityConsole console = GetComponent <UnityConsole>(); console.body.Clear(); console.Cursor = Coord.Zero; console.Window.viewRect.Position = Coord.Zero; console.Window.UpdatePosition(); }
public void Cmd_Dir(Command.Exec e) { List <KeyValuePair <string, object> > list = Listing(workingTransform); UnityConsole console = GetComponent <UnityConsole>(); for (int i = 0; i < list.Count; ++i) { console.WriteLine(list[i].Key); } }
public void Cmd_Pwd(Command.Exec e) { UnityConsole console = GetComponent <UnityConsole>(); string pwd = "/"; if (workingTransform != null) { pwd += workingTransform.HierarchyPath(); } console.WriteLine(pwd); }
public void Init(UnityConsole console) { if (cursor != null) { UnityConsoleCursor ucc = cursor.GetComponent <UnityConsoleCursor>(); if (ucc == null) { ucc = cursor.AddComponent <UnityConsoleCursor>(); } ucc.Initialize(console.Text.fontSize); } }
public void SetWorldSpaceCanvas() { uiTransform.SetParent(_worldSpaceCanvas.transform, false); if (disabledRectMask2d) { UnityConsole console = GetComponent <UnityConsole>(); RectMask2D rm2d = console.inputField.textViewport.GetComponent <RectMask2D>(); disabledRectMask2d = false; rm2d.enabled = true; } ActivateConsoleInput(consoleInputActive == ConsoleUiState.WorldSpace || consoleInputActive == ConsoleUiState.Both); EnqueueConsoleTextRefresh(); }
public void DoCommand(string text) { UnityConsole console = GetComponent <UnityConsole>(); CommanderInstance.ParseCommand(new Commander.Instruction(text, this), console.Write, out Tokenizer t); if (t?.errors?.Count > 0) { console.PushForeColor(ConsoleColor.Red); console.WriteLine(t.GetErrorString()); Show.Log(t.GetErrorString()); console.PopForeColor(); } WhenCommandRuns?.Invoke(text); }
public void SetScreenSpaceCanvas() { uiTransform.SetParent(ScreenSpaceCanvas.transform, false); UnityConsole console = GetComponent <UnityConsole>(); if (console.inputField != null) { RectMask2D rm2d = console.inputField.textViewport != null?console.inputField.textViewport.GetComponent <RectMask2D>() : null; if (rm2d != null && rm2d.enabled) { disabledRectMask2d = true; rm2d.enabled = false; } } ActivateConsoleInput(consoleInputActive == ConsoleUiState.ScreenSpace || consoleInputActive == ConsoleUiState.Both); EnqueueConsoleTextRefresh(); }
public void RefreshCursorPosition(UnityConsole console) { if (cursor == null) { return; } if (cursorVisible && index >= 0) { Transform t = cursor.transform; Vector3 p = CalculateCursorPosition(); t.localPosition = p; t.rotation = console.transform.rotation; cursor.SetActive(true); } else { cursor.SetActive(false); } }
public void Cmd_Echo(Command.Exec e) { UnityConsole console = GetComponent <UnityConsole>(); StringBuilder sb = new StringBuilder(); for (int i = 1; i < e.tok.tokens.Count; ++i) { object result = e.tok.tokens[i].Resolve(e.tok, e.src); if (result == null) { result = ""; } if (!(result is string)) { result = result.StringifySmall(); } sb.Append(result.ToString()); } console.WriteLine(sb.ToString()); }
private void Reset() { UnityConsole console = GetComponent <UnityConsole>(); UnityConsoleCommander consoleCommander = GetComponent <UnityConsoleCommander>(); if (consoleCommander != null) { EventBind.On(inputListener, consoleCommander, nameof(consoleCommander.DoCommand)); } KeyBind(KCode.Equals, KModifier.AnyCtrl, "+ console font", nameof(console.AddToFontSize), 1f, console); KeyBind(KCode.Minus, KModifier.AnyCtrl, "- console font", nameof(console.AddToFontSize), -1f, console); KeyBind(KCode.Return, KModifier.NoShift, "submit console input", nameof(FinishCurrentInput), target: this); KeyBind(KCode.C, KModifier.AnyCtrl, "copy from command console", nameof(CopyToClipboard), target: this); KeyBind(KCode.V, KModifier.AnyCtrl, "paste into command console", nameof(PasteFromClipboard), target: this); KeyBind(KCode.UpArrow, KModifier.AnyAlt, "move cursor up", nameof(MoveCursorUp), target: this); KeyBind(KCode.LeftArrow, KModifier.AnyAlt, "move cursor left", nameof(MoveCursorLeft), target: this); KeyBind(KCode.DownArrow, KModifier.AnyAlt, "move cursor down", nameof(MoveCursorDown), target: this); KeyBind(KCode.RightArrow, KModifier.AnyAlt, "move cursor right", nameof(MoveCursorRight), target: this); KeyBind(KCode.UpArrow, KModifier.AnyShift, "shift window up", nameof(ShiftWindowUp), target: this); KeyBind(KCode.LeftArrow, KModifier.AnyShift, "shift window left", nameof(ShiftWindowLeft), target: this); KeyBind(KCode.DownArrow, KModifier.AnyShift, "shift window down", nameof(ShiftWindowDown), target: this); KeyBind(KCode.RightArrow, KModifier.AnyShift, "shift window right", nameof(ShiftWindowRight), target: this); }
private void Awake() { console = GetComponent <UnityConsole>(); }