當前位置: 首頁>>代碼示例>>C#>>正文


C# Bounds.Add方法代碼示例

本文整理匯總了C#中UnityEngine.Bounds.Add方法的典型用法代碼示例。如果您正苦於以下問題:C# Bounds.Add方法的具體用法?C# Bounds.Add怎麽用?C# Bounds.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.Bounds的用法示例。


在下文中一共展示了Bounds.Add方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetAABB

        // Thanks to taniwha's Extraplanetary launchpads!
        public Bounds GetAABB(ShipConstruct a_Ship)
        {
            PartHeightQuery partHeight = null;
            Bounds aabb = new Bounds();
            bool initialize = true;
            for (int i = 0; i < a_Ship.parts.Count; i++)
            {
                Part currentPart = a_Ship[i];
                Collider[] colliders = currentPart.transform.FindChild("model").GetComponentsInChildren<Collider>();
                for (int j = 0; j < colliders.Length; j++)
                {
                    Collider currentCollider = colliders[j];

                    if (currentCollider.gameObject.layer != 21 && currentCollider.enabled) // Not sure where the 21 is coming from, have to ask taniwha
                    {
                        if (initialize)
                        {
                            initialize = false;
                            aabb = currentCollider.bounds;
                        }
                        else
                        {
                            aabb.Add(currentCollider.bounds);
                        }

                        float lowest = currentCollider.bounds.min.y;
                        if(partHeight == null)
                        {
                            partHeight = new PartHeightQuery(lowest);
                        }
                        partHeight.lowestPoint = Mathf.Min(partHeight.lowestPoint, lowest);

                        if(partHeight.lowestOnParts.ContainsKey(currentPart))
                        {
                            partHeight.lowestOnParts[currentPart] = Mathf.Min(partHeight.lowestOnParts[currentPart], lowest);
                        }
                    }
                }
            }

            for(int i = 0; i < a_Ship.parts.Count; i++)
            {
                a_Ship[i].SendMessage("OnPutToGround", partHeight, SendMessageOptions.DontRequireReceiver);
            }

            return new Bounds();
        }
開發者ID:MauriceH1,項目名稱:KSP_MobileConstruction,代碼行數:48,代碼來源:VesselWrapper.cs


注:本文中的UnityEngine.Bounds.Add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。