public override bool ExecuteCommand(DeveloperConsoleProvider host, ref string result, string[] arguments)
 {
     host.Print("Current computer informations:");
     host.Print("Graphics card: " + SystemInformations.graphicsDeviceName);
     host.Print("Processor: " + SystemInformations.processorType);
     host.Print("RAM: " + SystemInformations.systemMemorySize + " MB");
     host.Print("Operating system: " + SystemInformations.operatingSystem + "\n ");
     return(true);
 }
        private void Start()
        {
            if (!isConsoleAllowed)
            {
                mainUI.SetActive(false);
                Destroy(gameObject);
            }

            if (!multiConsolesAllowed)
            {
                if (Current != null)
                {
                    mainUI.SetActive(false);
                    Destroy(gameObject);
                }
                else
                {
                    Current = this;
                }
            }

            if (autoConnectModules)
            {
                modules.AddRange(FindObjectsOfType <ConsoleModule>());
            }

            if (autoSetTips)
            {
                foreach (ConsoleModule module in modules)
                {
                    tips.Add(module.command);
                }

                foreach (Alias alias in aliases)
                {
                    tips.Add(alias.alias);
                }
            }

            if (!Directory.Exists(logsPath))
            {
                logsPath = Path.Combine(Application.dataPath, "developerconsolelogs.txt");
            }
            else
            {
                logsPath = Path.Combine(logsPath, "developerconsolelogs.txt");
            }
        }
 /// <summary>
 /// Executes command.
 /// </summary>
 /// <param name="host"></param>
 /// <param name="result"></param>
 /// <param name="arguments"></param>
 /// <returns></returns>
 public virtual bool ExecuteCommand(DeveloperConsoleProvider host, ref string result, string[] arguments)
 {
     result = "";
     return(false);
 }
예제 #4
0
        public override bool ExecuteCommand(DeveloperConsoleProvider host, ref string result, string[] arguments)
        {
            MonoBehaviour target    = null;
            string        valueName = "";
            ValueType     valueType = ValueType.Integer;

            foreach (var val in values)
            {
                if (arguments[0] == val.valueName)
                {
                    target    = val.target;
                    valueName = val.valueName;
                    valueType = val.valueType;
                }
            }

            if (target == null)
            {
                result = CommandResults.WRONG_ARGS_MESS;
                return(false);
            }

            Type      objType = target.GetType();
            FieldInfo field   = objType.GetField(valueName);

            float  floatVal  = 0f;
            int    intVal    = 0;
            string stringVal = "";
            bool   boolVal   = false;
            bool   isOk      = false;

            if (field == null)
            {
                result = CommandResults.WRONG_COMMAND_MESS;
                return(false);
            }

            if (valueType == ValueType.Integer)
            {
                isOk = int.TryParse(arguments[1], out intVal);
            }
            else if (valueType == ValueType.Float)
            {
                isOk = float.TryParse(arguments[1], out floatVal);
            }
            else if (valueType == ValueType.Boolean)
            {
                isOk = bool.TryParse(arguments[1], out boolVal);
            }
            else if (valueType == ValueType.String)
            {
                stringVal = arguments[1];
                isOk      = true;
            }

            if (!isOk)
            {
                result = CommandResults.WRONG_ARGS_MESS;
                return(false);
            }

            if (valueType == ValueType.Integer)
            {
                field.SetValue(target, intVal);
            }
            else if (valueType == ValueType.Float)
            {
                field.SetValue(target, floatVal);
            }
            else if (valueType == ValueType.Boolean)
            {
                field.SetValue(target, boolVal);
            }
            else if (valueType == ValueType.String)
            {
                field.SetValue(target, stringVal);
            }

            return(true);
        }