using System; using System.Collections.Generic; using UnityEngine; [ExecuteInEditMode] [AddComponentMenu("NGUI/Internal/Draw Call")] public class UIDrawCall : MonoBehaviour { public enum Clipping { None = 0, TextureMask = 1, SoftClip = 3, ConstrainButDontClip = 4 } public delegate void OnRenderCallback(Material mat); private static BetterList mInactiveList = new BetterList(); [NonSerialized] [HideInInspector] public int widgetCount; [NonSerialized] [HideInInspector] public UIPanel panel; private Material mMaterial; private Texture mTexture; private Shader mShader; private int mClipCount; private Material mDynamicMat; private bool mRebuildMat = true; private bool mLegacyShader; [NonSerialized] public bool isDirty; [NonSerialized] private bool mTextureClip; 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; } } } public bool isClipped => mClipCount != 0; private bool IsWizardMaterial() { if (mMaterial.shader.name == "Wizard/VariantSleeveShader") { return true; } return false; } private bool IsSleeveMaterial() { if (mMaterial.name.Contains("sleeve")) { return true; } return false; } 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(); } }