/// <summary> /// Finds the root parent canvas of this GameObject. /// </summary> /// <returns>The root canvas's GameObject. Returns null if no GameObject's with Canvas /// components are found or if the no Canvas is marked as the root canvas.</returns> private static GameObject FindRootCanvas(GameObject gameObject) { Canvas[] canvases = gameObject.GetComponentsInParent<Canvas>(); if (canvases.Length == 0) { Debug.LogWarning("[DrawTextOnGUI] No Canvases currently loaded!"); return null; } foreach (Canvas c in canvases) if (c.isRootCanvas) return c.gameObject; Debug.LogWarningFormat("[DrawTextOnGUI] {0} Canvases, but no root Canvas found?", canvases.Length); return null; }
public static int GetStencilID(GameObject obj) { int count = 0; m_maskComponents = obj.GetComponentsInParent<Mask>(); for (int i = 0; i < m_maskComponents.Length; i++ ) { if (m_maskComponents[i].MaskEnabled()) count += 1; } switch (count) { case 0: return 0; case 1: return 1; case 2: return 3; case 3: return 11; } return 0; }
/// <summary> /// Function to get the Stencil ID /// </summary> /// <param name="obj"></param> /// <returns></returns> public static int GetStencilID(GameObject obj) { int count = 0; var maskComponents = TMP_ListPool<Mask>.Get(); obj.GetComponentsInParent<Mask>(false, maskComponents); for (int i = 0; i < maskComponents.Count; i++) { #if UNITY_5_2 || UNITY_5_3 || UNITY_5_4 if (maskComponents[i].IsActive()) count += 1; #else if (maskComponents[i].MaskEnabled()) count += 1; #endif } TMP_ListPool<Mask>.Release(maskComponents); return Mathf.Min((1 << count) - 1, 255); }
public static int GetStencilID(GameObject obj) { int count = 0; m_maskComponents = obj.GetComponentsInParent<Mask>(); for (int i = 0; i < m_maskComponents.Length; i++ ) { #if UNITY_5_2 || UNITY_5_3 //Debug.Log("Mask Enabled = " + m_maskComponents[i].enabled); if (m_maskComponents[i].IsActive()) count += 1; #else if (m_maskComponents[i].MaskEnabled()) count += 1; #endif } //switch (count) //{ // case 0: // return 0; // case 1: // return 1; // case 2: // return 3; // case 3: // return 7; //} //return 0; return Mathf.Min((1 << count) - 1, 255); }
public static int GetStencilID(GameObject obj) { int count = 0; m_maskComponents = obj.GetComponentsInParent<Mask>(); for (int i = 0; i < m_maskComponents.Length; i++ ) { #if UNITY_5_2 || UNITY_5_3 || UNITY_5_4 //Debug.Log("Mask Enabled = " + m_maskComponents[i].enabled); if (m_maskComponents[i].IsActive()) count += 1; #else if (m_maskComponents[i].MaskEnabled()) count += 1; #endif } return Mathf.Min((1 << count) - 1, 255); }