当前位置: 首页>>代码示例>>C#>>正文


C# GameObject.GetComponentsInParent方法代码示例

本文整理汇总了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;
        }
开发者ID:WandowsVR,项目名称:VRBikeOculusGame,代码行数:22,代码来源:DrawTextOnGUI.cs

示例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;
        }
开发者ID:SamSeidenberg,项目名称:DGames,代码行数:25,代码来源:MaterialManager.cs

示例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);
        }
开发者ID:Reticulatas,项目名称:Embargo,代码行数:27,代码来源:TMP_MaterialManager.cs

示例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);

            }
开发者ID:arahis,项目名称:Swiper,代码行数:34,代码来源:MaterialManager.cs

示例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);
        }
开发者ID:SamSeidenberg,项目名称:jackrabbitgame,代码行数:19,代码来源:MaterialManager.cs


注:本文中的UnityEngine.GameObject.GetComponentsInParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。