Hi Chris!
I want to update the name of a hotspot in code, during gameplay.
Updating the name of the hotspot and even its AltLabel was easy enough, but the thing is the Hotspot Menu that shows the names of clicked hotspots doesn't seem to care about changes made to the hotspot's name. It just shows the name the hotspot had by default, even though I can see in the editor that the name of the hotspot has now changed.
I have tried:
this.name = "New name"; on the gameObject containing the hotspot
And this:
this.GetComponent<AC.Hotspot>().SetName("New name", this.GetComponent<AC.Hotspot>().lineID);
Any ideas?
Comments
This is what the Hotspot: Rename Action does.
public string GetName (int languageNumber)
{
string newName = gameObject.name;
if (hotspotName != "")
{
newName = hotspotName;
}
if (languageNumber > 0)
{
return SpeechManager.GetTranslation (newName, displayLineID, languageNumber);
}
return newName;
}
You'll then need to manually override the new name's lineID, because passing -1 to the SetName function actually prevents it being overwritten as a safeguard. Once you've amended the function above, run this after calling SetName:
myHotspot.displayLineID = -1;