111 lines
1.9 KiB
C#
111 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[ExecuteInEditMode]
|
|
[AddComponentMenu("NGUI/Internal/Draw Call")]
|
|
public class UIDrawCall : MonoBehaviour
|
|
{
|
|
public enum Clipping
|
|
{
|
|
None = 0,
|
|
SoftClip = 3,
|
|
ConstrainButDontClip = 4
|
|
}
|
|
|
|
public delegate void OnRenderCallback(Material mat);
|
|
|
|
private static BetterList<UIDrawCall> mInactiveList = new BetterList<UIDrawCall>();
|
|
|
|
[NonSerialized]
|
|
[HideInInspector]
|
|
public int widgetCount;
|
|
|
|
private Material mMaterial;
|
|
|
|
private Texture mTexture;
|
|
|
|
private Shader mShader;
|
|
|
|
private Material mDynamicMat;
|
|
|
|
private bool mRebuildMat = true;
|
|
|
|
[NonSerialized]
|
|
public bool isDirty;
|
|
|
|
private static int[] ClipRange = null;
|
|
|
|
private static int[] ClipArgs = null;
|
|
|
|
public Texture mainTexture
|
|
{
|
|
get
|
|
{
|
|
return mTexture;
|
|
}
|
|
set
|
|
{
|
|
mTexture = value;
|
|
if (mDynamicMat != null)
|
|
{
|
|
mDynamicMat.mainTexture = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public Shader shader
|
|
{
|
|
get
|
|
{
|
|
return mShader;
|
|
}
|
|
set
|
|
{
|
|
if (mShader != value)
|
|
{
|
|
mShader = value;
|
|
mRebuildMat = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if (ClipRange == null)
|
|
{
|
|
ClipRange = new int[4]
|
|
{
|
|
Shader.PropertyToID("_ClipRange0"),
|
|
Shader.PropertyToID("_ClipRange1"),
|
|
Shader.PropertyToID("_ClipRange2"),
|
|
Shader.PropertyToID("_ClipRange4")
|
|
};
|
|
}
|
|
if (ClipArgs == null)
|
|
{
|
|
ClipArgs = new int[4]
|
|
{
|
|
Shader.PropertyToID("_ClipArgs0"),
|
|
Shader.PropertyToID("_ClipArgs1"),
|
|
Shader.PropertyToID("_ClipArgs2"),
|
|
Shader.PropertyToID("_ClipArgs3")
|
|
};
|
|
}
|
|
}
|
|
|
|
public static void ReleaseInactive()
|
|
{
|
|
int num = mInactiveList.size;
|
|
while (num > 0)
|
|
{
|
|
UIDrawCall uIDrawCall = mInactiveList[--num];
|
|
if ((bool)uIDrawCall)
|
|
{
|
|
NGUITools.DestroyImmediate(uIDrawCall.gameObject);
|
|
}
|
|
}
|
|
mInactiveList.Clear();
|
|
}
|
|
}
|