Hello GiL,
I'd like to let players change some graphics quality options from my pause menu.
I've added a pause menu screen and a "button list" menu item of type "Menu Screen" that takes me to my options menu screen.
What I'd like to do is; use "Custom Choice Settings" like in Main Menu/Menu Options/ so I can search for a Game Object and call the necessary functions.
Right now I can add an "Option" instead of a "Button List" from the Menu Screens. And add an "Option" type of "Custom" which has a "Value type " setting such as "Value","Game Variable"...but I can't understand where that value is and how I can use it to change my custom options.
I'm planning an "Advanced Graphics Options" menu which I hope will let users to change most graphics settings so I really need to understand this and if possible use "Custom Choice Settings" and use a script to control those settings.
Thanks.
You can access game variables through the global variable handler:
ORK.Game.Variables
E.g.: accessing the bool:
ORK.Game.Variables.GetBool("custom_option");
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I found it under Editor.
So I now add a game variable called "custom_option" from the Editor tab but it doesn't have any way to set its type.
Later, I go to my option and set this "game variable " to input type of "Bool" there. I'm guessing this'll work as a toggle. But What if something else tries to use this variable as string within ORK?
And as the last step I'll make a script that uses "ORK.Game.Variables" namespace and use the way you show to access the variable.
Isn't it possible to use the same system as the main menu uses?
We search for a GO and a component and send a variable to that function.
I'm asking this because in my ORK main menu by clicking to a button; I switch to a script based GUI (close ork main menu) and do something and return back to ORK's main menu.
If possible I'd like to do this with my pause menu as well.
Thanks GiL
ORK.Game.Variables isn't a namespace, you need to use the ORKFramework namespace.
You can still do something similar like in the main menu in your menu screens - the button list can also call Global Events for a button. Set up a game event that calls your custom code and use it as a global event.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I'm trying your suggestion;
I've added a button list to my pause menu which calls a Global event(Execution type "call") and as for the event itself;
I've added an actor which searches for a name and then the "call function" step which finds the component and calls the function (debug_test). Everything is OK if I have this in my function;
public void debug_test()
{
Debug.Log("huhuuu!!");
}
but if I use;
public void debug_test()
{
Transform options_canvas = transform.Find("options");
foreach (Transform child in options_canvas)
{
child.gameObject.SetActive (true);
}
Debug.Log("huhuuu!!");
}
Unity starts complaining...saying;
Method call failed (test): debug_test
Exception has been thrown by the target of an invocation.
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000eb] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115
at ORKFramework.Reflection.CallMethod.Call (System.Object instance) [0x00000] in <filename unknown>:0
UnityEngine.Debug:LogWarning(Object)
ORKFramework.Reflection.CallMethod:Call(Object)
ORKFramework.Events.Steps.CallFunctionStep:Continue(BaseEvent)
ORKFramework.Events.Steps.CallFunctionStep:Execute(BaseEvent)
ORKFramework.Events.GameEvent:ExecuteNextStep()
ORKFramework.Events.BaseEvent:StartEvent()
ORKFramework.Events.GameEvent:StartEvent(IEventStarter, GameObject)
ORKFramework.Events.GlobalEvent:Call()
ORKFramework.<CallGlobalEvent2>d__0:MoveNext()
so when I use a "foreach" things get hot :)
Unfortunately this is nearly the same way I show my Bug report panel from the Main menu.
Is this a problem about the event system?
And also (if possible) Can you explain why don't we have the same functionality as the main menu for the other menus? Isn't it easier to search and call a function from a button?
Thanks GiL
The custom choice in the main menu and the options menu are two different things. For the menu screens, you can do this using an event calling button (which also allows doing much more).
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
But seeing an error like that I thought it was related to ORK. In a normal usage (without ORK) that would give a NullReferanceException in Unity console.
So ORK collects errors and displays in its own way. Is that so?
On a related topic; As my pause menu is coming up, I see one frame of it as its being scaled up. It's hard to describe so I made a short video of it;
https://www.dropbox.com/s/oym508otpx0qjyr/pause_menu0001-0376.mp4?dl=0
In the video you can see me accessing to pause menu with the "esc" key few times and on some of those, a smaller pause menu screen can be seen for a few frames.
What might be causing this? Might be a beta thing (V5 b17)
I mostly used the default settings.
Thanks GiL, I now can access and use default Unity UI tools if I need to:)
Say I go to my Options menu with a button list on my pause menu that calls a global event which eventually calls my options function...
After I'm done with my options how should I go back to that pause menu?
This is not a main menu so I think it's related to either "ORK.MenuScreens" or "ORK.Menu" but not sure. There is a "closeall" but nothing like "Show"
The scaling thing is probably caused by the move in/out scaling settings of the GUI box :)
If it's not that, than it's probably a Unity 5 beta thing...
Game events can also call menus.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I see the "Add Console Line" step but is there anyway of attaching this node to a any step in case of an error.
I've checked the move in/out , they're disabled but still this might be because of the beta. So I'll keep an eye out on this. And if this continues I'll let you know :)
Another question about menus and scripting is;
How can I re show my menu screen after I'm done with my custom options menu?
My custom script is handling the graphics options and after I'm done with it I'd like to press a button and call an ORK menu back. Do I call a game event that uses a "Call Menu Screen" step?
ORK.MenuScreens.Get(int index).Show();
index is the ID of the menu screen.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I've made a script that facilitates .Get() and .Show() thanks for that.
But I've another menu related issue;
I have a menu screen that is activated with "Esc" key.
It has the following settings;
http://www.mediafire.com/view/b95yhqof7qdx7x9
and menu look like:
http://www.mediafire.com/view/e99vp63cdovksqa
While the game is running, the first time I hit the "Esc" key menu pops up but I need to hit "Esc" twice to make it close.
And If I call the pause menu a second time I need to hit "Esc" key twice to make it show.
If I activate the "Pause Settings" (All enabled) everything works as expected. One "esc" key brings the menu second closes it...and so on!
Am I doing something wrong?
Can you send me a stripped down test project? Just a scene where I can call the menu :)
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
It's a beta 21 project (I hope you have the beta)
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Made it!
Sent it!
:)