DevConsole

DevConsole

A tools for someone who still love the command console.
allow trigger something by user input.
this is a framework to let developer easier add custom command to this console.
** you will need DevManager to run this script. **

Feature :

  • AddCommand() / DelCommand()
  • Command with params
  • Simply extends methods, Create your tools. 😀

Usage :

  1. Create a empty gameobject, add “DevConsole.cs” at than object.
    DevManager_info012
  2. Create and design your own script.
    we have sample code in pro packet, you may start there.
    • Example :
      MyCustomFucktionBasic.cs
      using UnityEngine;
      using System.Collections.Generic;
      
      public class MyCustomFunctionBasic : DevelopManager.ExtendCommand // <-- extends class
      {
      	public Texture2D BigHead;
      
      
      	void Start() {
      		AddCommand("say", "[DEMO] Repeat your message.", TalkToMe);
      		// DelCommand("say");
      		AddCommand("time","[DEMO] Display current time.", CurrentTime);
      	}
      
      
      	// DoSomething should return List<GUIContent> or null
      	public List<GUIContent> CurrentTime(string[] _args)
      	{
      		List<GUIContent> _rst = new List<GUIContent>();
      		_rst.Add(new GUIContent("Time : "+ System.DateTime.Now.ToLongDateString() ));
      		return _rst;
      	}
      
      
      	public List<GUIContent> TalkToMe(string[] _args)
      	{
      		List<GUIContent> _rst = new List<GUIContent>();
      		// You can use Image. as your output result.
      		if( BigHead ) _rst.Add(new GUIContent(BigHead));
      		// _args[] is user's input string behind setting command.
      		_rst.Add(new GUIContent("Say : "+ string.Join(" ",_args) ));
      		return _rst;
      	}
      }
      
  3. After you ready this script file. add your custom script file on Gameobject.
    DevManager_info013
    E.g. we added “MyCustomFunctionBasic.cs” & “MyCustomFunctionAdvanced.cs”
    on Gameobject who contain “DevConsole.cs”
  4. Start the game.
  5. Open up DevManager menu (Default key : scroll lock)
  6. Switch on “DevConsole” on Dock. then you will see the GUIWindow like this.
    DevManager_info014

Code Reference : 

  1. Don’t forget to extends class “DevelopManager.ExtendCommand
  2. AddCommand Method
    public bool AddCommand(string _name,string _description,TheCommand _callback)
    will return true when success added.
  3. DelCommand Method
    public bool DelCommand(string _name)
    will return true when success delete.
  4. The Call back function must return a List<GUIContent> result.
    public List<GUIContent> YourFunction(string[] _params)
    {
    	List<GUIContent> _rst = new List<GUIContent>();
    	
    	// Do something here.
    	
    	// return the output GUIContent to DevConsole.
    	return _rst;
    }

The end of DevConsole description.

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *

*