I am attempting to make a global MaterialAssign
script that I can assign to anything and have an enum
selector in the inspector to assign a material type. This would then drive hitFX and soundFX variation in other scripts.
My selector script MaterialAssign.cs:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MaterialAssign : MonoBehaviour
{
public enum MatSelection
{
defaultMat,
metalEnemy,
metalWall,
dirtWall
}
public static MatSelection currentMat;
}
Attempt at usage in another script:
if (MaterialAssign.currentMat == MaterialAssign.MatSelection.metalEnemy)
{
selectedHitFX = bulletMetalEnemyFX;
}
else if (MaterialAssign.currentMat == MaterialAssign.MatSelection.metalWall)
{
selectedHitFX = bulletMetalWallFX;
}
I have no errors in the console BUT the enum selector doesn't show up in the inspector, so I'm assuming no value is ever passed. I read that enums can't have a static value, but not sure how to handle that.
Any assistance would be most appreciated or alternate approaches welcome! I'm purposely trying to stay away from tags, but can go down that path if needed.