I have a panel for a point and click adventure style game with a constant nav on the bottom of the screen using the 4.6 ui.
i have triange on my ps3 as the button to activate the other panel, another navigation menu for items, keys, docs, options, and save/load… sort of like darksouls i guess. I want my shoulder buttons to nav these buttons.
this would turn on at the top of my screen, and the 1st nav should turn off.
I’ve set the exam button as first selected in the event system. since i can’t add 2 or more event systems in a single scene, when i activate the top nav, there is no selected or selectable button. The 1st panel is explicit left / right/up/down transition and it relates to my joypad dpad. and panel 2 is horizontal which should respond to my L1 and R1 buttons.
A user named Orb helped me get to the point of using SetSelectedGameObject() but I cannot find much documentation on using these new functions… methods?? I’m a UnityScript guy.
The problem is weird:
the items button highlights, and on left or right dpad press it wants to go to the next item but snaps back to items. the R1 and L1 make my print() shows the next button as being selected in console but it snaps right back to the items button.
the menus open and close fine so far. i’m realyl going to need to master this to work in more sub menus. It’s too bad i cant just have more than 1 event system.
Thank you for any help!!!
Here is the code:
#pragma strict
import UnityEngine.EventSystems;
public var main_canvas : GameObject;
public var screen_nav_panel : GameObject;
public var inv_nav_panel : GameObject;
public var diag_box : GameObject;
public var diag_text : GameObject;
private var inventoryon : boolean;
private var diagon : boolean;
private var itemon : boolean;
public var exam_button : GameObject;
public var items_button : GameObject;
public var docs_button : GameObject;
public var keys_button : GameObject;
public var options_button : GameObject;
public var saveload_button : GameObject;
public var event_object : GameObject;
var event_system : UnityEngine.EventSystems.EventSystem;
var exam_button_logic : ExamButton;
var es : EventSystem;
function Start ()
{
// either this is correct
event_system = event_object.GetComponent(EventSystems.EventSystem);
//or this
es = EventSystemManager.currentSystem;
main_canvas = this.gameObject;
exam_button_logic = exam_button.GetComponent(ExamButton);
screen_nav_panel.SetActive(true);
inv_nav_panel.SetActive(false);
diag_box.SetActive(false);
diag_text.SetActive(false);
inventoryon = false;
diagon = false;
itemon = false;
}
function Update ()
{
// refference each nav button.
// while exam is selected / highlighted
if(exam_button_logic.exam_selected == true)
{
if(Input.GetButtonDown("Submit"))
{
diagon = true;
}
else
if(Input.GetButtonDown("Cancel"))
{
diagon = false;
}
}
else
if(exam_button_logic.exam_selected == false)
{
diagon = false;
}
//////////////////////////////////////////////////////////////
// turn on inventory
if(Input.GetButtonDown("Inventory"))
{
inventoryon = true;
diagon = false;
screen_nav_panel.SetActive(false);
inv_nav_panel.SetActive(true);
}
//////////////////////////////////////////////////////////////////
// when inventory is meant to be on
if(inventoryon == true)
{
itemon = true;
es.SetSelectedGameObject(items_button, null);
}
else
if(inventoryon == false)
{
itemon = false;
screen_nav_panel.SetActive(true);
inv_nav_panel.SetActive(false);
}
if(itemon == true)
{
if(Input.GetButtonDown("L1"))
{
itemon = false;
es.SetSelectedGameObject(saveload_button, null);
print(event_system.currentSelectedObject);
}
else
if(Input.GetButtonDown("R1"))
{
itemon = false;
es.SetSelectedGameObject(docs_button, null);
print(event_system.currentSelectedObject);
}
else
if(Input.GetButtonDown("Cancel"))
{
itemon = false;
es.SetSelectedGameObject(exam_button, null);
inventoryon = false;
print(event_system.currentSelectedObject);
}
}
// when diag is meant to be on
if(diagon == true)
{
diag_box.SetActive(true);
diag_text.SetActive(true);
if(Input.GetButtonDown("Cancel"))
{
diagon = false;
}
}
else
if(diagon == false)
{
diag_box.SetActive(false);
diag_text.SetActive(false);
}
}