Page 1 of 1

Assistance With Var Casting

Posted: Thu Mar 14, 2024 11:56 pm
by l3lessed
I'm having an issue with casting this Enum var to a new empty var. I'm getting the implicitly casting error, but I can't understand why. I think I'm casting it explicitly. Here's the code, if someone can help me understand this.

Here is the basic casting error:
Assets\Game\Mods\Minimap\Scripts\BuildingManager.cs(577,43): error CS0266: Cannot implicitly convert type 'Minimap.MarkerGroups [D:\Games\daggerfall-unity-master\Assets\Game\Mods\Minimap\Scripts\Minimap.cs(24)]' to 'Minimap.MarkerGroups [D:\Games\daggerfall-unity-master\Library\ScriptAssemblies\Assembly-CSharp.dll]'. An explicit conversion exists (are you missing a cast?)
This is the line causing the issue. MarkerGroupID variable is the integer conversion for the enum MarkerGroups value being assigned.

Code: Select all

                MeshController meshScript = combinedMesh.AddComponent<MeshController>();
                meshScript.buildingType = (MarkerGroups)markerGroupID;
This is the var being setup in the Meshcontroller script, which it is assigning/casting to.

Code: Select all

public MarkerGroups buildingType = new MarkerGroups();
Here is the public enum it is using to cast from

Code: Select all

public enum MarkerGroups
{
    Shops,
    Blacksmiths,
    Houses,
    Taverns,
    Utilities,
    Government,
    Friendlies,
    Enemies,
    Resident,
    Doors,
    None
}