Beispiel #1
0
        private void Start()
        {
            //we can add our own type to the StringToType system
            StringToType.SetConverterDelegateForType(
                typeof(ConsoleStaticCommandsTest.SomethingSupported),
                (s) => { return(new ConsoleStaticCommandsTest.SomethingSupported()
                {
                    val = int.Parse(s)
                }); });

            //we temp bind the error log to nothing, so we aren't spammed during adding items we know will
            //  have lots of failures.
            var prevLog = ConsoleBindingHelper.OnErrorLogDelegate;

            ConsoleBindingHelper.OnErrorLogDelegate = delegate { };

            //binding a class intended to have all static items added
            ConsoleBindingHelper.AddAllToConsole(null, null, typeof(ConsoleStaticCommandsTest));

            //binding a specific instance to the console
            ConsoleBindingHelper.AddAllToConsole(instTest, "instTest");

            //binding a class that is a monostate/c# wrapper around a singleton from Unity
            ConsoleBindingHelper.AddAllToConsole(null, null, typeof(Physics));

            Console.Log("Try entering Console.AddStaticTypeByString Physics2D");

            //restore the logger
            ConsoleBindingHelper.OnErrorLogDelegate = prevLog;
        }
Beispiel #2
0
    // Start is called before the first frame update
    private void Start()
    {
        ConsoleBindingHelper.OnErrorLogDelegate = BindingLog;
        ConsoleBindingHelper.AddAllToConsole(null, null, typeof(Physics));

        if (bindingErrors.Count > 0)
        {
            UnityEngine.Debug.LogWarning(bindingErrors.Count.ToString() + " errors during AddAll Physics");
        }

        ConsoleBindingHelper.OnErrorLogDelegate = UnityEngine.Debug.LogError;
        bindingErrors.Clear();
    }
Beispiel #3
0
        public static void AddStaticTypeByString(string typeName)
        {
            var alltypes = System.AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes());

            var t = alltypes.FirstOrDefault(x => x.Name == typeName);

            if (t == null)
            {
                Console.Log("Could not find type of name " + typeName + ". Make sure you are using the correct namespaces, nestedclass and assembly.");
                return;
            }

            ConsoleBindingHelper.AddAllToConsole(null, null, t);
            Console.Log("Found " + typeName + " in " + t.Assembly.FullName);
        }