Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Cast to Enum type fails #62

Closed
ikuko opened this issue Nov 5, 2020 · 2 comments
Closed

Cast to Enum type fails #62

ikuko opened this issue Nov 5, 2020 · 2 comments
Assignees
Labels
blocked-vrc Blocked due to missing underlying functionality or relying on some underspecified system enhancement New feature or request

Comments

@ikuko
Copy link

ikuko commented Nov 5, 2020

Describe the bug in detail:
Cast to Enum type fails

Provide steps/code to reproduce the bug:

public class TEST : UdonSharpBehaviour
{
    public Light component;
    private void Start()
    {
        component.type = (LightType)0;
    }
}

Expected behavior:

[<color=yellow>UdonBehaviour</color>] An exception occurred during Udon execution, this UdonBehaviour will be halted.
VRC.Udon.VM.UdonVMException: The VM encountered an error!
Exception Message:
  An exception occurred during EXTERN to 'UnityEngineLight.__set_type__UnityEngineLightType__SystemVoid'.
      Parameter Addresses: 0x00000026, 0x0000026C
  
  Cannot retrieve heap variable of type 'Int32' as type 'LightType'

Additional Information:
I think other enum types will give similar results

@ikuko ikuko added the bug Something isn't working label Nov 5, 2020
@MerlinVR
Copy link
Owner

MerlinVR commented Nov 5, 2020

This has been waiting on VRC to add handling for int to enum conversions

But seeing as nothing has been exposed in Udon other than built-in Unity functions in the last year, I can look at adding forwarding to object array indices since enum arrays are also missing which will generate a bunch of garbage, but will let it work at least.

@MerlinVR MerlinVR added blocked-vrc Blocked due to missing underlying functionality or relying on some underspecified system enhancement New feature or request and removed bug Something isn't working labels Nov 5, 2020
@ikuko
Copy link
Author

ikuko commented Nov 16, 2020

I dealt with it with the following code.
Not a good code -;

int lightType = 1;// LightType.Directional
switch (lightType)
{
    case 0: return LightType.Spot;
    case 1: return LightType.Directional;
    case 2: return LightType.Point;
    case 3: return LightType.Area;
}

@MerlinVR MerlinVR self-assigned this Nov 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked-vrc Blocked due to missing underlying functionality or relying on some underspecified system enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants