Xbox One and Set active on GameObject
When I run game in Unity3D editor on my laptop it will let me flip objects between active and inactive, but when I run the same game on Xbox One I can set GameObjects to be inactive but then it won't let me set them to active again. I think it might be destroying the objects when I set to Inactive. Any Suggestions on how to handle or if that is correct understanding of problem. (I guess I could spawn the objects when I need them, but seems wastful)
Any idea on what I might be doing wrong? On does Xbox dev just not support setactive?
Answer by Zealot35 · Jun 25, 2018 at 02:41 AM
Can you show us the snippet of code you use? And are you using unityscript or c#?
Answer by alexrau · Jun 25, 2018 at 10:26 AM
Here is the function that I am using which works on dev laptop but not Xbox. Is a C# script.
private void checkIfSwitchCharacters()
{
var inputDevice = InputManager.ActiveDevice;
if ((inputDevice.LeftTrigger.WasPressed) || (inputDevice.RightTrigger.WasPressed))
{
currentCharacterArrayPosition = currentCharacterArrayPosition + 1;
if (currentCharacterArrayPosition >= 2)
{
currentCharacterArrayPosition = 0;
}
currentCharacterGameObject.SetActive( false);
playerAnimator = charactersAnimators[currentCharacterArrayPosition];
currentCharacterGameObject = charactersGameObjects[currentCharacterArrayPosition];
currentCharacterGameObject.SetActive(true);
}
}
Any idea on what I might be doing wrong? On does Xbox dev just not support setactive?
Answer by RLord321 · Oct 27, 2020 at 01:19 AM
XBOX supports setActive. I'm 100% certain what your problem is. The Unity Editor and other deployments do not give you the same order of GameObjects when you are retrieving them from your scene in your code. For example, if you have more than 1 object with the same tag and you get all the objects by tag, on your computer you could get object1, object2, and object3 and on the XBOX, you could get object3, object1, object2.
Good Luck!