Exemple #1
0
    public override void OnInspectorGUI()
    {
        Light2D l = (Light2D)target;

        l.IsStatic      = EditorGUILayout.Toggle(new GUIContent("Is Static", "Static lights will not cast shadows in 'Play' mode. They will however cast shadows in edit mode."), l.IsStatic);
        l_Detail        = (Light2D.LightDetailSetting)EditorGUILayout.EnumPopup("Detail", l.LightDetail);
        l_Color         = EditorGUILayout.ColorField("Light Color", l.LightColor);
        l.LightMaterial = (Material)EditorGUILayout.ObjectField("Material", l.LightMaterial, typeof(Material), false);

        l_Layer = EditorGUILayout.LayerField("Layer", l.ShadowLayer - 1);

        EditorGUILayout.Separator();

        l.useEvents = EditorGUILayout.Toggle("Enable Events", l.useEvents);
        l.allowHideInsideColliders = EditorGUILayout.Toggle("Hide In Colliders", l.allowHideInsideColliders);
        l.ignoreOptimizations      = EditorGUILayout.Toggle("Continuous Update", l.ignoreOptimizations);

        EditorGUILayout.Separator();

        l_SweepStart = Mathf.Clamp(EditorGUILayout.FloatField("Sweep Start", l.SweepStart), -360, 360);
        l_SweepSize  = (int)Mathf.Clamp(EditorGUILayout.IntField("Sweep Size", l.SweepSize), 0, 360);
        l_Radius     = Mathf.Clamp(EditorGUILayout.FloatField("Light Radius", l.LightRadius), 0.02f, Mathf.Infinity);

        if (GUI.changed)
        {
            l.LightDetail = l_Detail;
            l.LightRadius = l_Radius;
            l.SweepSize   = l_SweepSize;
            l.SweepStart  = l_SweepStart;
            l.LightColor  = l_Color;
            l.ShadowLayer = 1 << l_Layer;
            l.UpdateLight2D();
        }
    }