Exemple #1
0
        /// ====================================================================================
        /// Extend this class into a per-game custom commands script.
        /// Fill it with the functions you want to be able to call from the console.
        /// RULES
        /// 1. THESE FUNCTIONS MUST BE PUBLIC
        /// 2. FOR EASE OF TYPING IN-GAME THESE FUNCTIONS SHOULD BE ALL LOWERCASE
        /// 3. IF YOU WANT TO PASS ARGUMENTS:
        ///     3A. CREATE A PRIVATE FUNCTION WITH NO ARGUMENTS
        ///     3B. CREATE A PUBLIC FUNCTION OF THE SAME NAME WITH NO BODY, GIVE IT YOUR ARGUMENTS
        ///     3C. USE console.inputArgument IN THE PRIVATE FUNCTION TO UTILIZE THE INFORMATION
        ///     3D. SEE argumentfunction BELOW AS AN EXAMPLE
        /// ====================================================================================
        ///
        public void lua()
        {
            string code = "";

            foreach (string s in console.args)
            {
                Debug.Log(s);
                code += s + " ";
            }
            UConsole.NewEvent(World.current.LuaString(code));
        }
Exemple #2
0
 public void Init()
 {
     //WorldController.Instance.cbRegisterReady(Init);
     Debug.Log("init " + this.name);
     initialised            = true;
     wcon                   = WorldController.Instance;
     cam                    = Camera.main;
     tileSize               = World.current.tileSize;
     HALF_tileSize          = tileSize / 2;
     bCon                   = WorldController.Instance.buildController;
     bCon.inputCon          = this;
     cam.transform.position = new Vector3(World.current.width / 2, World.current.height / 2, cam.transform.position.z);
     cursorPrefab           = Instantiate(cursorPrefab, this.transform.position, Quaternion.identity);
     cursorPrefab.transform.SetParent(this.transform, true);
     cursorPrefab.SetActive(false);
     //cursorPrefab.GetComponent<SpriteRenderer>().sprite = NYDISpriteManager.Instance.GetSprite("other::cursor_slice_2");
     uConsoleGO  = WorldController.Instance.uConsoleObject;
     UConsoleObj = uConsoleGO.GetComponent <UConsole>();
     //WorldController.Instance.uConsoleObject.SetActive(false);
 }
Exemple #3
0
        void Start()
        {
            instance = this;

            commands    = GetComponent <UConsoleCommands>();
            canvas      = GetComponent <CanvasGroup>();
            inputField  = transform.Find("InputField").GetComponent <InputField>();
            suggestions = transform.Find("ConsoleSuggestions").GetComponent <Text>();
            eventLog    = transform.Find("EventLog").GetComponent <Text>();

            methods.AddRange(commands.GetType().GetMethods(flags));
            methods.Sort((x, y) => string.Compare(x.Name, y.Name)); // Order alphabetically

            /*foreach(MethodInfo m in methods) // Enable to print a list of grabbed methods
             *  Debug.Log(m.Name);*/
            eventLog.text = "";

            // Subtle deactivation
            inputField.DeactivateInputField();
            inputField.enabled = false;
            canvas.alpha       = 0;
        }
Exemple #4
0
 public void mynewfunction()
 {
     UConsole.NewEvent("New Function was called.");
 }
Exemple #5
0
 private void argumentfunction()
 {
     UConsole.NewEvent("Your argument was: " + console.inputArgument);
 }
Exemple #6
0
 public void testfunction()
 {
     UConsole.NewEvent("If you see this in the event log, testfunction was successfully called!");
 }
Exemple #7
0
 protected void Start()
 {
     console = GetComponent <UConsole>();
 }