- Home /
In-Game Console and Permanent Variable Changes
Hey Guys!
So I have spent the last few hours getting to grips with Reflection and MethodInfo, etc,
And I've managed to write a custom in-game console which displays all functions with a specific key word, and their parameters(types, and optional), etc.
The way I call the functions across every asset using the targeted script is with:
"MethodInfo.Invoke"
The problem I'm having now, is that any public variables I change in game, such as whether a component is enabled, it keeps that state upon existing play mode.
It was my belief that the variables returned to their original/user-defined state upon returning to editor mode.
Am I doing something wrong?
Or am I going to have to create private versions of everything I want to edit with the console, and set them from the public on Start?
Thanks in advanced guys!
Oh and you can have the console script if you want!
It can call any function with any number of parameters!
(I've only written a parser for int, float, string, Vector2 and Vector3 so far)
Thanks again!
Answer by Loken_01 · Nov 30, 2014 at 10:43 PM
Hey Guys!
I actually fixed it, and figured I should post the solution in case anyone else has this problem.
My console was invoking a method I chose for every 'MonoBehaviour' of the Method's matching System.Type;
The problem was that it wasn't just affecting the instantiated game-time version,
but the inspector version too.
The simple solution was when I was invoking a method, making sure that the 'MonoBehaviour's 'HideFlags' were equal to 'None'!
So! Done and dusted!
Thanks again guys!
Your answer
Follow this Question
Related Questions
Use a String Variable to Dynamically Invoke a Method 1 Answer
SendMessage vs MethodInfo.Invoke 1 Answer
Anyone know how to get Type.GetMethods( ...) to return private methods? 1 Answer
How to refrerence a changing variable without using GetComponent 4 Answers
I'm unable to clear a variable that is used in multiple scripts. 0 Answers