示例#1
0
    // Lighting Buffers
    void DrawLightingBuffers(float z)
    {
        foreach (LightingBuffer2D id in LightingBuffer2D.GetList())
        {
            if (id.lightSource != null)
            {
                if (id.lightSource.isActiveAndEnabled == false)
                {
                    continue;
                }

                LightingManager2D.LightingDebug.LightSourceDrawn += 1;

                Vector3 pos  = id.lightSource.transform.position - Camera.main.transform.position;
                float   size = id.bufferCamera.orthographicSize;

                Color lightColor = id.lightSource.lightColor;
                lightColor.a = id.lightSource.lightAlpha / 2;

                id.material.SetColor("_TintColor", lightColor);

                Max2D.iDrawImage(id.material, new Vector2D(pos), new Vector2D(size, size), z);
            }
        }
    }
 void DrawLightingBuffers(float z)
 {
     // Lighting Buffers
     foreach (LightingBuffer2D id in LightingBuffer2D.GetList())
     {
         if (id.lightSource != null)
         {
             if (id.lightSource.isActiveAndEnabled)
             {
                 Vector3 pos  = id.lightSource.transform.position - Camera.main.transform.position;
                 float   size = id.bufferCamera.orthographicSize;
                 Max2D.iDrawImage(id.material, new Vector2D(pos), new Vector2D(size, size), z);
             }
         }
     }
 }
示例#3
0
    static public LightingBuffer2D GetBuffer(int textureSize, LightingSource2D lightSource)
    {
        foreach (LightingBuffer2D id in LightingBuffer2D.GetList())
        {
            if ((id.lightSource == lightSource || id.lightSource == null) && id.textureSize == textureSize)
            {
                id.lightSource          = lightSource;
                lightSource.update      = true;
                id.bufferCamera.enabled = true;
                //id.gameObject.SetActive (true);
                return(id);
            }
        }

        return(AddBuffer(textureSize));
    }
        static public void OnGUI()
        {
            if (timer == null)
            {
                LightingDebug.timer = TimerHelper.Create();
            }
            if (timer.GetMillisecs() > 1000)
            {
                ShowLightBufferUpdates = LightBufferUpdates;

                LightBufferUpdates = 0;

                timer = TimerHelper.Create();
            }
            GUI.Label(new Rect(10, 10, 200, 20), "Light Buffer Updates: " + ShowLightBufferUpdates);
            GUI.Label(new Rect(10, 30, 200, 20), "Light Buffer Count: " + LightingBuffer2D.GetList().Count);
        }
        static public void OnGUI()
        {
            if (timer == null)
            {
                LightingDebug.timer = TimerHelper.Create();
            }
            if (timer.GetMillisecs() > 1000)
            {
                ShowLightBufferUpdates = LightBufferUpdates;

                LightBufferUpdates = 0;

                ShowLightMainBufferUpdates = LightMainBufferUpdates;

                LightMainBufferUpdates = 0;

                ShowLightMainCameraUpdates = LightMainCameraUpdates;

                LightMainCameraUpdates = 0;

                timer = TimerHelper.Create();
            }

            ShowLightSourceDrawn = LightSourceDrawn;

            LightSourceDrawn = 0;

            GUI.Label(new Rect(10, 10, 200, 20), "Light Buffer Updates: " + ShowLightBufferUpdates);
            GUI.Label(new Rect(10, 30, 200, 20), "Light Main Buffer Updates: " + ShowLightMainBufferUpdates);
            GUI.Label(new Rect(10, 50, 200, 20), "Light Main Camera Updates: " + ShowLightMainCameraUpdates);
            GUI.Label(new Rect(10, 70, 200, 20), "Light Buffer Count: " + LightingBuffer2D.GetList().Count);
            GUI.Label(new Rect(10, 90, 200, 20), "Light Collider Count: " + LightingCollider2D.GetList().Count);

            Texture texture = LightingMainBuffer2D.Get().bufferCamera.activeTexture;

            GUI.Label(new Rect(10, 110, 200, 20), "Main Buffer Resolution: " + texture.width + "x" + texture.height);

            GUI.Label(new Rect(10, 130, 200, 20), "Light Sources Drawn: " + ShowLightSourceDrawn);
        }
示例#6
0
    static public LightingBuffer2D PullBuffer(int textureSize, LightingSource2D lightSource)
    {
        LightingManager2D manager = LightingManager2D.Get();

        if (manager.fixedLightBufferSize)
        {
            textureSize = LightingManager2D.GetTextureSize(manager.fixedLightTextureSize);
        }

        foreach (LightingBuffer2D id in LightingBuffer2D.GetList())
        {
            if (id.free == true && id.textureSize == textureSize)
            {
                id.bufferCamera.orthographicSize = lightSource.lightSize;
                lightSource.update = true;
                id.lightSource     = lightSource;             // Unnecessary?
                id.free            = false;
                //id.gameObject.SetActive (true);
                return(id);
            }
        }

        return(AddBuffer(textureSize, lightSource));
    }