Exemplo n.º 1
0
    /// <summary>
    /// Easy static function for creating 2D lights.
    /// </summary>
    /// <param name="_position">Sets the position of the created light</param>
    /// <param name="_lightMaterial">Sets the Material of the light</param>
    /// <param name="_lightColor">Sets the color of the created light</param>
    /// <param name="_lightRadius">Sets the radius of the created light. [If Directional this is equal to LightBeamSize]</param>
    /// <param name="_lightConeAngle">Sets the cone angle of the light. [If Directional this is equal to LightBeamRange]</param>
    /// <param name="_lightDetail">Sets the detail of the light</param>
    /// <param name="_useEvents">If 'TRUE' event messages will be sent.</param>
    /// <param name="_lightType">Sets what type of light will be rendered. [Directional, Radial, Shadow]</param>
    /// <returns>Returns the created Light2D object, NOT the gameobject.</returns>
    public static Light2D Create(Vector3 _position, Material _lightMaterial, Color _lightColor, float _lightRadius = 1, int _lightConeAngle = 360, LightDetailSetting _lightDetail = LightDetailSetting.Rays_500, bool _useEvents = false, LightTypeSetting _lightType = LightTypeSetting.Radial)
    {
        GameObject obj = new GameObject("New 2D-" + _lightType.ToString());
        obj.transform.position = _position;

        Light2D l2D = obj.AddComponent<Light2D>();
        l2D.LightMaterial = _lightMaterial;
        l2D.LightColor = _lightColor;
        l2D.LightDetail = _lightDetail;

        if (_lightType != Light2D.LightTypeSetting.Directional)
        {
            l2D.LightRadius = _lightRadius;
            l2D.LightConeAngle = _lightConeAngle;
        }
        else
        {
            l2D.LightBeamSize = _lightRadius;
            l2D.LightBeamRange = _lightConeAngle;
        }
        
        l2D.ShadowLayer = -1;
        l2D.EnableEvents = _useEvents;
        l2D.LightType = _lightType;

        return l2D;
    }
Exemplo n.º 2
0
 /// <summary>
 /// Easy static function for creating 2D lights.
 /// </summary>
 /// <param name="_position">Sets the position of the created light</param>
 /// <param name="_lightColor">Sets the color of the created light</param>
 /// <param name="_lightRadius">Sets the radius of the created light</param>
 /// <param name="_lightConeAngle">Sets the cone angle of the light</param>
 /// <param name="_lightDetail">Sets the detail of the light</param>
 /// <param name="_useEvents">If 'TRUE' event messages will be sent.</param>
 /// <param name="_lightType">Sets what type of light will be rendered. [Directional, Radial, Shadow]</param>
 /// <returns>Returns the created Light2D object, NOT the gameobject.</returns>
 public static Light2D Create(Vector3 _position, Color _lightColor, float _lightRadius = 1, int _lightConeAngle = 360, LightDetailSetting _lightDetail = LightDetailSetting.Rays_500, bool _useEvents = false, LightTypeSetting _lightType = LightTypeSetting.Radial)
 {
     return Create(_position, (Material)Resources.Load("RadialLight"), _lightColor, _lightRadius, _lightConeAngle, _lightDetail, _useEvents, _lightType);
 }
Exemplo n.º 3
0
    /// <summary>
    /// Easy static function for creating 2D lights.
    /// </summary>
    /// <param name="_position">Sets the position of the created light</param>
    /// <param name="_lightMaterial">Sets the Material of the light</param>
    /// <param name="_lightColor">Sets the color of the created light</param>
    /// <param name="_lightRadius">Sets the radius of the created light</param>
    /// <param name="_lightConeAngle">Sets the cone angle of the light</param>
    /// <param name="_lightDetail">Sets the detail of the light</param>
    /// <param name="_useEvents">If 'TRUE' event messages will be sent.</param>
    /// <param name="_isShadow">If 'TRUE' light will be inverted to generate shadow mesh.</param>
    /// <returns>Returns the created Light2D object, NOT the gameobject.</returns>
    public static Light2D Create(Vector3 _position, Material _lightMaterial, Color _lightColor, float _lightRadius = 1, int _lightConeAngle = 360, LightDetailSetting _lightDetail = LightDetailSetting.Rays_500, bool _useEvents = false, bool _isShadow = false)
    {
        GameObject obj = new GameObject("New Light");

        obj.transform.position = _position;

        Light2D l2D = obj.AddComponent <Light2D>();

        l2D.LightMaterial   = _lightMaterial;
        l2D.LightColor      = _lightColor;
        l2D.LightDetail     = _lightDetail;
        l2D.LightRadius     = _lightRadius;
        l2D.LightConeAngle  = _lightConeAngle;
        l2D.ShadowLayer     = -1;
        l2D.EnableEvents    = _useEvents;
        l2D.IsShadowEmitter = _isShadow;

        return(l2D);
    }
Exemplo n.º 4
0
    public static Light2D Create(Vector3 position, Material lightMaterial, Color lightColor, float lightRadius, float sweepStart, int sweepSize, LightDetailSetting detailSetting)
    {
        GameObject go = new GameObject("Created Light");

        go.transform.position = position;

        Light2D nLight = go.AddComponent <Light2D>();

        nLight.lightMaterial = lightMaterial;
        nLight.lightColor    = lightColor;
        nLight.lightRadius   = lightRadius;
        nLight.sweepStart    = sweepStart;
        nLight.sweepSize     = sweepSize;
        nLight.lightDetail   = detailSetting;

        return(nLight);
    }
Exemplo n.º 5
0
 /// <summary>
 /// Easy static function for creating 2D lights.
 /// </summary>
 /// <param name="_position">Sets the position of the created light</param>
 /// <param name="_lightColor">Sets the color of the created light</param>
 /// <param name="_lightRadius">Sets the radius of the created light</param>
 /// <param name="_lightConeAngle">Sets the cone angle of the light</param>
 /// <param name="_lightDetail">Sets the detail of the light</param>
 /// <param name="_useEvents">If 'TRUE' event messages will be sent.</param>
 /// <param name="_isShadow">If 'TRUE' light will be inverted to generate shadow mesh.</param>
 /// <returns>Returns the created Light2D object, NOT the gameobject.</returns>
 public static Light2D Create(Vector3 _position, Color _lightColor, float _lightRadius = 1, int _lightConeAngle = 360, LightDetailSetting _lightDetail = LightDetailSetting.Rays_500, bool _useEvents = false, bool _isShadow = false)
 {
     return(Create(_position, (Material)Resources.Load("RadialLight"), _lightColor, _lightRadius, _lightConeAngle, _lightDetail, _useEvents, _isShadow));
 }