I got a error where it says: A game object can only be in one layer. The layer needs to be in the range [0...31]. Here is my code:
string remoteLayerName = "RemotePlayer";
[SerializeField]
string dontDrawLayerName = "DontDraw";
[SerializeField]
GameObject playerGraphics;
[SerializeField]
GameObject playerUIPrefab;
[HideInInspector]
public GameObject playerUIInstance;
void Start ()
{
// Disable components that should only be
// active on the player that we control
if (!isLocalPlayer)
{
DisableComponents();
AssignRemoteLayer();
}
else
{
// Disable player graphics for local player
SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));
// Create PlayerUI
playerUIInstance = Instantiate(playerUIPrefab);
playerUIInstance.name = playerUIPrefab.name;
}
GetComponent().Setup();
}
void SetLayerRecursively (GameObject obj, int newLayer)
{
obj.layer = newLayer;
foreach (Transform child in obj.transform)
{
SetLayerRecursively(child.gameObject, newLayer);
}
}
If anyone knows how to fix this i would want to know :)
↧