本文整理汇总了C#中UnityEngine.GameObject.GetComponentsInParent方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.GetComponentsInParent方法的具体用法?C# GameObject.GetComponentsInParent怎么用?C# GameObject.GetComponentsInParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.GameObject
的用法示例。
在下文中一共展示了GameObject.GetComponentsInParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindRootCanvas
/// <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;
}
示例2: GetStencilID
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;
}
示例3: GetStencilID
/// <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);
}
示例4: GetStencilID
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);
}
示例5: GetStencilID
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);
}