Hi all, I’ve been trying to find a solution for this for almost 4 hours but still nothing.
I have a character mesh which is made of multiple meshes (the hair, the shirt, the shorts). When the ChangeForm input is given, I need to turn off the shorts and shirt skinned Mesh Renderer. For some reason, I can turn it off but it won’t turn on again. I also tried pacing the script in another gameobject, but still it doesn’t work.
using UnityEngine;
using System.Collections;
public class ToggleVisibility : MonoBehaviour
{
//VARS//
private PlayerState _player;
private InputManager _inputManager;
public GameObject top;
public GameObject shorts;
private SkinnedMeshRenderer topMesh;
private SkinnedMeshRenderer shortsMesh;
public enum PlayerState
{
NormalForm,
EtherealForm,
}
// Use this for initialization
void Start()
{
_inputManager = FindObjectOfType<InputManager>();
_inputManager.OnChangeForm += ChangeForm;
_player = PlayerState.NormalForm;
topMesh = top.GetComponent<SkinnedMeshRenderer>();
shortsMesh = shorts.GetComponent<SkinnedMeshRenderer>();
}
private void ChangeForm()
{
switch (_player)
{
case PlayerState.NormalForm:
{
topMesh.enabled = false;
shortsMesh.enabled = false;
break;
}
case PlayerState.EtherealForm:
{
topMesh.enabled = true;
shortsMesh.enabled = true;
Debug.Log("enabled mesh renderer");
break;
}
default:
//if i'm here i'm dead so do nothing
break;
}
}
}