edited January 2015 in ORK Support
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.
  • The Custom options allows changing game variables, e.g. if you want to change a bool variable with the key 'custom_option', you'll need to select the value type Value and set the value to custom_option.

    You can access game variables through the global variable handler:

    ORK.Game.Variables

    E.g.: accessing the bool:

    ORK.Game.Variables.GetBool("custom_option");
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I must have forgotten that Ork has a variable system called "Game Variable" :)
    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

  • You don't need to add game variables in the editor tab - that's actually more of an information tab to show what variables are used where in your game. You can also define variables there to populate the drop down list in the variable fields. Variables defined here wont automatically be added in the game - they're only added when used somewhere (e.g. events).

    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.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Aaa!! now I understand why "game variables " were under Editor tab :)

    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
  • edited January 2015
    You should probably check things in your function before accessing them, e.g. if the options_canvas is null or the child is null, etc.

    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).
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Sorry you were right:) I was searching for the wrong GO.
    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:)

  • edited January 2015
    heh :) one more short question about this

    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"
    Post edited by gurayg on
  • edited January 2015
    ORK only catches those errors when using reflection (e.g. in case of the Call Function) node, because a wrongly defined function name would otherwise cause the event to break, which would in some cases (e.g. blocking events) also break the game.

    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.
    Post edited by gamingislove on
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Good to know about ORK's inner workings :)
    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?
  • If you're doing this in your custom code, you can also call the menu screen directly using this code:

    ORK.MenuScreens.Get(int index).Show();

    index is the ID of the menu screen.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited January 2015
    Sorry GiL if this is taking so long...

    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;


    image

    http://www.mediafire.com/view/b95yhqof7qdx7x9

    and menu look like:

    image

    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?
    Post edited by gurayg on
  • Not happening here - you only have to press it twice if you're currently viewing a different screen, than you'll need one press to bring the menu again and another to close it.
    Can you send me a stripped down test project? Just a scene where I can call the menu :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I've sent a small project to community mail.
    It's a beta 21 project (I hope you have the beta)
  • Sorry, beta versions aren't supported - either recreate your problem in a Unity 4.6 project or wait if it still occurs in the official release version of Unity 5.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Got it!
    Made it!
    Sent it!
    :)
Sign In or Register to comment.