Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity Class not exposing all parameters...

Discussion in 'Scripting' started by LightStriker, Jul 5, 2014.

  1. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    I just noticed the Light class lack the settings to edit;

    - Halo
    - Lightmapping

    Those two settings shows up fine in the Inspector, but are no where to be found in the API.

    What's going on here?
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    reflection?
     
  3. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    Nope, the class itself doesn't have those parameters.

    Here's the light class definition;

    Code (CSharp):
    1.     public sealed class Light : Behaviour
    2.     {
    3.         public Light();
    4.  
    5.         public bool alreadyLightmapped { get; set; }
    6.         public Vector2 areaSize { get; set; }
    7.         [Obsolete("light.attenuate was removed; all lights always attenuate now", true)]
    8.         public bool attenuate { get; set; }
    9.         public Color color { get; set; }
    10.         public Texture cookie { get; set; }
    11.         public float cookieSize { get; set; }
    12.         public int cullingMask { get; set; }
    13.         public Flare flare { get; set; }
    14.         public float intensity { get; set; }
    15.         [Obsolete("Use QualitySettings.pixelLightCount instead.")]
    16.         public static int pixelLightCount { get; set; }
    17.         public float range { get; set; }
    18.         public LightRenderMode renderMode { get; set; }
    19.         public float shadowBias { get; set; }
    20.         [Obsolete("light.shadowConstantBias was removed, use light.shadowBias", true)]
    21.         public float shadowConstantBias { get; set; }
    22.         [Obsolete("light.shadowObjectSizeBias was removed, use light.shadowBias", true)]
    23.         public float shadowObjectSizeBias { get; set; }
    24.         public LightShadows shadows { get; set; }
    25.         public float shadowSoftness { get; set; }
    26.         public float shadowSoftnessFade { get; set; }
    27.         public float shadowStrength { get; set; }
    28.         public float spotAngle { get; set; }
    29.         public LightType type { get; set; }
    30.  
    31.         [WrapperlessIcall]
    32.         public static Light[] GetLights(LightType type, int layer);
    33.     }
    And it's not the first time I encounter a Unity type that is lacking some of the parameters it exposes in the Inspector.
     
    IvanAuda likes this.
  4. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Can't agree with you more; super frustrating. It literally forces you to do everything in the hierarchy/inspector :(
     
  5. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Not sure about Halo but you can get at lightmapping like this...

    Code (csharp):
    1.  
    2. SerializedObject serialObj = new SerializedObject(childLight);
    3. SerializedProperty lightmapProp = serialObj.FindProperty("m_Lightmapping");
    4. if(lightmapProp != null && lightmapProp.enumNames[lightmapProp.enumValueIndex] == "BakedOnly")
    5. {
    6. }
    7.  
     
  6. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    Sorry, but even that is not super useful. SerializedObject/SerializedProperty are both UnityEditor namespace. Well, someone could say that the Lightmapping value aren't really useful at runtime, but the halo one is. I'm surprised even the Lightmapping enum doesn't exist in the UnityEngine's assembly.
     
    Last edited: Jul 5, 2014
    IvanAuda likes this.
  7. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Yeah, it's not awesome. For SECTR I use code like this in the editor and then cache the results for use at runtime. Then again, I only need to read, not write, the data.