vendredi 24 juin 2016

Unity BlendMode

Im pretty new to unity and i had written a simple 2 layer day night system in flash AS3. But im not sure how i could achieve the same thing in unity

This is the AS3 code i was using. It simply adds a black square to the back ground with addNight(). Then addLight() adds a gradient circle to the screen. The effect of light/dark is achieved with

spr.blendMode = BlendMode.LAYER;


bound.blendMode = BlendMode.ERASE;

  • Im currently working with c# in unity

    public var spr:Sprite = new Sprite();
    var msk:Sprite = new Sprite();
    private var gType:String;  
    private var matrix:Matrix;  
    private var bound:Sprite;
    public function addNight()
        spr.alpha = .85;
   ;,0 ,800,600);;
        spr.blendMode = BlendMode.LAYER;
    public function addLight(x:int, y:int)
        var gType:String = GradientType.RADIAL;  
        var matrix:Matrix = new Matrix();  
        var gColors:Array = [0xFFFFFF, 0x000000];  
        var gAlphas:Array = [.9,0];  
        var gRatio:Array = [0,255];  
        var bound:Sprite = new Sprite(); ,gColors,gAlphas,gRatio,matrix); ,150,150);
        bound.x = bound.y = 0;  
        bound.x = x;
        bound.y = y;
        bound.blendMode = BlendMode.ERASE;

I should also mention, i'm working with Unity2D. Im also willing to use a completely different way of achieving a lighting system

Aucun commentaire:

Enregistrer un commentaire