コード例 #1
0
 /// <summary>
 /// Awake function getting all the references in need and also adding a few basic commands
 /// </summary>
 protected override void Awake()
 {
     graphData = new Queue <float>();
     MemoryTracer.SetDebugComponent(this);
     consoleOutBuffer = new Queue <string>();
     consoleOutBuffer.Enqueue("Console Initialized..");
     title              = Owner.GetChildWithName("Title").GetComponent <UiTextRendererComponent>();
     consoleInput       = Owner.GetChildWithName("ConsoleInput").GetComponent <UiTextRendererComponent>();
     consoleOutput      = Owner.GetChildWithName("ConsoleOutput").GetComponent <UiTextRendererComponent>();
     bgImage            = Owner.GetChildWithName("BackgroundImage").GetComponent <UiImageRendererComponent>();
     hintText           = Owner.GetChildWithName("HintText").GetComponent <UiTextRendererComponent>();
     graph              = Owner.GetChildWithName("Graph").GetComponent <GraphDrawingComponent>();
     graph.Enabled      = false;
     consoleOutputImage =
         Owner.GetChildWithName("BackgroundOutputImage").GetComponent <UiImageRendererComponent>();
     sb    = new StringBuilder();
     outSb = new StringBuilder();
     AddCommand("help", cmd_ListCmds);
     AddCommand("h", cmd_ListCmds);
     AddCommand("q", cmd_Exit);
     AddCommand("exit", cmd_Exit);
     AddCommand("quit", cmd_Exit);
     AddCommand("cls", cmd_Clear);
     AddCommand("clear", cmd_Clear);
     AddCommand("lmem", MemoryTracer.CmdListMemoryInfo);
     AddCommand("llmem", MemoryTracer.CmdListLastMemoryInfo);
     AddCommand("cmd", CmdExOnConsole);
     AddCommand("tg", cmd_ToggleGraph);
     AddCommand("togglegraph", cmd_ToggleGraph);
     AddCommand("reload", cmd_ReLoadScene);
     AddCommand("load", cmd_LoadScene);
     AddCommand("listscenes", cmd_ListScenes);
     AddCommand("ls", cmd_ListScenes);
 }
コード例 #2
0
        /// <summary>
        /// Static function that will assemble the Console
        /// </summary>
        /// <returns>A gameobject ready to be added to the game</returns>
        public static GameObject CreateConsole()
        {
            GameObject obj      = new GameObject("Console");
            GameObject _in      = new GameObject("ConsoleInput");
            GameObject _out     = new GameObject("ConsoleOutput");
            GameObject titleObj = new GameObject("Title");
            GameObject bgObj    = new GameObject("BackgroundImage");
            GameObject bgOutObj = new GameObject("BackgroundOutputImage");
            GameObject hint     = new GameObject("HintText");
            GameObject graph    = new GameObject("Graph");

            obj.Add(_in);
            obj.Add(_out);
            obj.Add(titleObj);
            obj.Add(bgObj);
            obj.Add(hint);
            obj.Add(bgOutObj);
            obj.Add(graph);

            Bitmap bmp = new Bitmap(1, 1);

            bmp.SetPixel(0, 0, Color.Black);

            UiImageRendererComponent bgImage =
                new UiImageRendererComponent(TextureLoader.BitmapToTexture(bmp, "DebugConsoleBackground"), false, 0.65f,
                                             DefaultFilepaths.DefaultUiImageShader);

            UiImageRendererComponent bgOutImage =
                new UiImageRendererComponent(TextureLoader.BitmapToTexture(bmp, "DebugConsoleOutputBackground"), false,
                                             0.4f,
                                             DefaultFilepaths.DefaultUiImageShader);


            UiTextRendererComponent tText =
                new UiTextRendererComponent(DefaultFilepaths.DefaultFont, false, 1f,
                                            DefaultFilepaths.DefaultUiTextShader)
            {
                Text = "GameEngine Console:"
            };
            UiTextRendererComponent tHint =
                new UiTextRendererComponent(DefaultFilepaths.DefaultFont, false, 1f,
                                            DefaultFilepaths.DefaultUiTextShader)
            {
                Text = "GameEngine Console:"
            };

            UiTextRendererComponent tIn =
                new UiTextRendererComponent(DefaultFilepaths.DefaultFont, false, 1f,
                                            DefaultFilepaths.DefaultUiTextShader)
            {
                Text = ""
            };

            UiTextRendererComponent tOut =
                new UiTextRendererComponent(DefaultFilepaths.DefaultFont, false, 1f,
                                            DefaultFilepaths.DefaultUiTextShader)
            {
                Text = "Console Initialized.."
            };

            GraphDrawingComponent gDraw = new GraphDrawingComponent(DefaultFilepaths.DefaultUiGraphShader, false, 1f);

            bgOutObj.AddComponent(bgOutImage);
            bgObj.AddComponent(bgImage);
            graph.AddComponent(gDraw);
            _in.AddComponent(tIn);
            _out.AddComponent(tOut);
            titleObj.AddComponent(tText);
            hint.AddComponent(tHint);

            gDraw.Scale    = new Vector2(0.5f, 0.5f);
            gDraw.Position = new Vector2(0.5f);
            gDraw.Points   = new[]
            {
                new Vector2(0f, 0f),
                new Vector2(1f, 1f)
            };

            tText.Position = new Vector2(-0.39f, 0.353f) * 2;
            tText.Scale    = new Vector2(2f, 2f);

            tOut.Position = new Vector2(-0.33f, 0.31f) * 2;
            tOut.Scale    = new Vector2(0.8f, 0.8f);

            tIn.Position = new Vector2(-0.39f, -0.39f) * 2;
            tIn.Scale    = new Vector2(1.5f, 1.5f);


            tHint.Position = new Vector2(-0.46f, -0.46f) * 2;
            tHint.Scale    = new Vector2(1.5f, 1.5f);


            bgImage.Scale    = new Vector2(0.8f);
            bgOutImage.Scale = new Vector2(0.7f);

            obj.AddComponent(new DebugConsoleComponent());
            return(obj);
        }