Ejemplo n.º 1
0
        private void Awake()
        {
            DeveloperConsole.OnConsoleOpened    += OnConsoleOpened;
            DeveloperConsole.OnConsoleClosed    += OnConsoleClosed;
            DeveloperConsole.OnDirectoryChanged += OnDirectoryChanged;

            // Check if there is currently an EventSystem active.
            // If not, the UI will not work, and we must instantiate one
            if (EventSystem.current == null)
            {
                var eventSystemInstance = Instantiate(EventSystemPrefab);
                EventSystem.current = eventSystemInstance.GetComponent <EventSystem>();
            }

            mViewSettings                  = ConsoleSettings.GetViewSettings();
            Overlay.alpha                  = ConsoleSettings.ConsoleOverlayAlpha;
            InputField.fontAsset           = mViewSettings.Font;
            InputField.textComponent.color = mViewSettings.FontColor;
            InputField.pointSize           = mViewSettings.FontSize;

            // Configure input field prefix visuals
            var mPrefixRightMarginSizeAdjustment = InputFieldPrefix.TextComponent.margin.z / InputFieldPrefix.TextComponent.fontSize;

            InputFieldPrefix.Configure(mViewSettings);
            InputFieldPrefix.TextComponent.margin = new Vector4(0, 0, mViewSettings.FontSize * mPrefixRightMarginSizeAdjustment, 0);

            // Get format for the console prefix
            mPrefixFormat = $"<color=#{ColorUtility.ToHtmlStringRGB(ConsoleSettings.ConsoleFilePathColor)}>{{0}}</color>";
            if (ConsoleSettings.ConsolePrefixCharacter != ' ')
            {
                mPrefixFormat += $" <color=#{ColorUtility.ToHtmlStringRGB(ConsoleSettings.ConsoleFontColor)}>{ConsoleSettings.ConsolePrefixCharacter}</color>";
            }

            InputField.onSubmit.AddListener(OnInputSubmitted);
            InputField.onValueChanged.AddListener(OnInputValueChanged);

            Scroll.onBeginDrag += _ => mCachedCaretPosition = InputField.caretPosition;
            Scroll.onEndDrag   += _ =>
            {
                InputField.ActivateInputField();
                InputField.caretPosition = mCachedCaretPosition;
            };

            OnConsoleClosed();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Called when the console is setting up this <see cref="ConsoleEntry"/> before it is fully rendered. Use to update any relevant visual content within the object based on the default settings contained in <paramref name="settings"/>.
 /// </summary>
 /// <param name="settings">A <see cref="ViewSettings"/> instance passed containing a bundle of console-wide visual settings.</param>
 public virtual void Configure(ViewSettings settings)
 {
 }