I would ask for some help , If I may - because I am completely stuck...
My Hotspots open a generic "custom" (Unity UI Prefab) menu from a 'Look at' interaction. (much like the Inventory demo) The menu contains possible user selections that are handled by a custom action when the choice is submitted.
Because both the menu and the "submit" action are generic I cannot define the hotspot to turn off in either action list.. My Question is.. how do I get/pass a reference to the clicked hotspot so that I can turn it off once it has achived my "used" status...
I have tried setting a global variable ("current_active_hotspot") in the look interaction- but am having problems targeting the hotspot when I grab it again , I have tried the Canvas EventSystem - but Hotspot selection actions are not registered by AC
I would guess the answer is staring me in the face - but being a total newbie.... I would humbly accept superior knowledge
Thanks in advance if you can help...
Comments
From your description, I would imagine you could make use of parameters to do this. Parameters are a way for you to change the content of Actions each time they're run, and you can use a GameObject parameter within the Hotspot: Enable or disable Action to change the affected Hotspot dynamically.
You can find a tutorial on their usage here. While parameters are usually set at the time their containing ActionList is run (using ActionList: Run), you can set the values of individual parameters at any time by using the ActionList: Set parameter Action.
I will read the tutorial and see what I can figure out. My guess is that this is quite a common scenario , so I will document a case solution / use example (when found) for the new wiki page(s) - trying to find an answer by extrapolating problem cases & questions was getting me nowhere: being a newbie I dont have the indepth knowledge to point myself in the right direction.
Thank you very much for your assistance.
OK - After the last action ( following the "Menu Off" call : in the case of an acceptable user input) you can use a custom action thus :
override public float Run(){
Hotspot myHotspot = AC.KickStarter.playerInteraction.GetLastOrActiveHotspot();
// validate : dont want to have a bad object ref ....
if (myHotspot != null) {
myHotspot.TurnOff (true);
} else {
Debug.Log ("Oh Duckpants - I must have made a Boo Boo ! Lost the Hotspot");
}
return 0f;
}
And : Discoveries -
(1) AC. namespace has to be defined for the reference in Run() scope - can anybody confirm ?
(2) Using this method does not require a global var to be set - you don't even have to know the target of course :-)
(3) GetActiveHotspot() does not work (returns Null as soon as the first click is made / first opertunity to test comes about) - at least in my project that is what happens
4) this works with other menus being opened and closed during the process
I think this is possibly the cleanest way ?
+ Thank you Chris for the thouroughness of a method like GetLastOrActiveHotspot() :-) & please ignore my eventSystem question : this does the same job.
Nice solution. It's true that GetActiveHotspot is null at the time of an interaction - the Hotspot itself is de-selected before anything else.
For completeness, OnHotspotInteract is the event that runs when an Interaction is run, not OnHotspotSelect - that's just when it's highlighted.
Re: Hotspot to Mesh - I had misunderstood your 1.4.3(?) release comment about "now being able to wrap hotspots" - I presumed it meant wrap to 'shape' [ ? automaticaly cloning GameObjects mesh colider as the hotspots colider (and say increasing by 0.1 scale)... (which is what you can do, as you designed..) ] : but it is too labour intensive to do manualy with my quantity of Hotspots - so we are back to cubes for now - ATM . I am just grateful to be able to use the present wrap and not have to move from 0,0,0..... !
BTW - Very glad I found I can use a single instance of a "look-at" interaction as a generic action - nice little touch to speed things up :-)