Esempio n. 1
0
        private void Start()
        {
            if (BoundsObject == null)
            {
                BoundsObject = gameObject;
            }

            m_effectiveBoundsType = BoundsType;
            m_filter  = BoundsObject.GetComponent <MeshFilter>();
            m_skinned = BoundsObject.GetComponent <SkinnedMeshRenderer>();

            if (m_filter == null && m_skinned == null)
            {
                m_spriteRenderer = BoundsObject.GetComponent <SpriteRenderer>();
                //BoundsInWorldSpace = true;
            }

            if (m_rte.IsOpened)
            {
                TryToAddColliders();
            }
            else
            {
                TryToDestroyColliders();
                m_colliders = null; //do not move this inside of TryToDestroyColliders;
            }

            if (hideFlags != HideFlags.HideAndDontSave)
            {
                if (_Started != null)
                {
                    _Started(m_rte, this);
                }
            }
        }
Esempio n. 2
0
        private void Start()
        {
            if (BoundsObject == null)
            {
                BoundsObject = gameObject;
            }
            m_effectiveBoundsType = BoundsType;

            m_filter  = BoundsObject.GetComponent <MeshFilter>();
            m_skinned = BoundsObject.GetComponent <SkinnedMeshRenderer>();

            if (RuntimeEditorApplication.IsOpened)
            {
                TryToAddColliders();
            }
            else
            {
                TryToDestroyColliders();
                m_colliders = null; //do not move this inside of TryToDestroyColliders;
            }

            if (hideFlags != HideFlags.HideAndDontSave)
            {
                if (Started != null)
                {
                    Started(this);
                }
            }
        }
Esempio n. 3
0
        public BoundsMessage AddBounds(BoundsType boundsType)
        {
            var bounds = new BoundsMessage(OwnerDocument, boundsType);

            AppendChild(bounds);
            return(bounds);
        }
Esempio n. 4
0
 protected virtual void OnBoundsChanged(BoundsType boundsType)
 {
     if (BoundsChanged != null)
     {
         BoundsChanged(this, new BoundsChangedEventArgs(boundsType));
     }
 }
Esempio n. 5
0
        private void Awake()
        {
            Init();
            IsAwaked = true;

            m_effectiveBoundsType = BoundsType;
            m_filter  = BoundsObject.GetComponent <MeshFilter>();
            m_skinned = BoundsObject.GetComponent <SkinnedMeshRenderer>();

            if (m_filter == null && m_skinned == null)
            {
                m_spriteRenderer = BoundsObject.GetComponent <SpriteRenderer>();
            }

            bool visible = (hideFlags & HideFlags.HideInHierarchy) == 0;

            if (visible)
            {
                if (transform.parent != null && transform.parent.GetComponent <ExposeToEditor>() == null && transform.parent.tag != HierarchyRootTag)
                {
                    //gameObject.hideFlags = HideFlags.HideInHierarchy;
                    visible = false;
                    Debug.LogWarning(gameObject.name + ": parent GameObject is not exposed to editor");
                }
            }

            if (visible)
            {
                if (_Awaked != null)
                {
                    _Awaked(this);
                }
            }
        }
    public Bounds GetBounds(BoundsType boundsType = BoundsType.Default)
    {
        switch (boundsType)
        {
        case BoundsType.Base:
            return(GetBaseBounds());

        case BoundsType.Placement:
            return(GetPlacementBounds());
        }

        return(GetDefaultBounds());
    }
        protected override void ReadFromImpl(object obj)
        {
            base.ReadFromImpl(obj);
            ExposeToEditor uo = (ExposeToEditor)obj;

            Unselected   = uo.Unselected;
            BoundsObject = ToID(uo.BoundsObject);
            BoundsType   = uo.BoundsType;
            CustomBounds = uo.CustomBounds;
            CanSnap      = uo.CanSnap;
            AddColliders = uo.AddColliders;
            Colliders    = ToID(uo.Colliders);
        }
Esempio n. 8
0
        private static System.Type ComponentType(BoundsType boundsType)
        {
            switch (boundsType)
            {
            case BoundsType.Collider:
                return(typeof(Collider));

            case BoundsType.Collider2D:
                return(typeof(Collider2D));

            case BoundsType.Sprite:
                return(typeof(SpriteRenderer));
            }

            throw new System.NotImplementedException();
        }
        public static int DestroyBounds(BoundsType type)
        {
            int destroyedBounds = 0;

            foreach (GameObject o in Resources.FindObjectsOfTypeAll(typeof(GameObject)))
            {
                if (o.name != "BoundsAPI | " + type.ToString())
                {
                    continue;
                }

                GameObject.Destroy(o);
                destroyedBounds++;
            }

            return(destroyedBounds);
        }
Esempio n. 10
0
    private void UpdateShadowmapCameraParams(BoundsType boundsType)
    {
        if (boundsType == BoundsType.AABB)
        {
            for (int i = 0; i < CascadeStepNum; ++i)
            {
                List <Vector3> frustumVertex             = m_cameraFrustumList[i];
                AABBBounds     frustumBoundsOnLightSpace = GeometryUtility.GetAABBBoundsOnTargetSpace(Mainlight.transform, frustumVertex);

                CascadedShadowMapCameraParams cameraParams = new CascadedShadowMapCameraParams();
                cameraParams.cameraPosition       = new Vector3(frustumBoundsOnLightSpace.Center.x, frustumBoundsOnLightSpace.Center.y, frustumBoundsOnLightSpace.Min.z - 0.05f);
                cameraParams.cameraOrthogonalSize = Mathf.Max(frustumBoundsOnLightSpace.Extends.x, frustumBoundsOnLightSpace.Extends.y) / 2;           //todo:orthogonalSize算法需要以后好好研究一下
                cameraParams.cameraZSize          = frustumBoundsOnLightSpace.Size.z;

                m_shadowMapCameraParams.Add(cameraParams);
            }
        }
    }
Esempio n. 11
0
        public static Bounds GetBounds(Transform transform, BoundsType type = BoundsType.All, Collider excluded = null)
        {
            Bounds bounds = new Bounds {
                size = Vector3.zero
            };

            if (!transform)
            {
                return(bounds);
            }

            // Save initial rotation.
            Quaternion rotation = transform.localRotation;

            transform.localRotation = Quaternion.identity;
            bounds.center           = transform.position;

            if ((type == BoundsType.All) || (type == BoundsType.Collider))
            {
                Collider[] colliders = transform.GetComponentsInChildren <Collider>();
                foreach (Collider c in colliders)
                {
                    if (c != excluded)
                    {
                        bounds = CombineBounds(bounds, c.bounds);
                    }
                }
            }

            if ((type == BoundsType.All) || (type == BoundsType.Renderer))
            {
                Renderer[] renderers = transform.GetComponentsInChildren <Renderer>();
                foreach (Renderer renderer in renderers)
                {
                    bounds = CombineBounds(bounds, renderer.bounds);
                }
            }

            // Restore initial rotation.
            transform.localRotation = rotation;

            return(bounds);
        }
            public string expandChildren;   // 謎

            public Part(NodeReader node)
            {
                name        = node.AtText("name");
                index       = node.AtInteger("arrayIndex");
                parent      = node.AtInteger("parentIndex");
                type        = NodeTypeOperator.FromString(node.AtText("type"));
                boundsType  = BoundsTypeOperator.FromString(node.AtText("boundsType"));
                inheritType = InheritTypeOperator.FromString(node.AtText("inheritType"));
                //inheritRates
                blendType = AlphaBlendTypeOperator.FromString(node.AtText("alphaBlendType"));
                show      = node.AtBoolean("show");

                var n = node.ChildOrNull("expandAttribute");

                expandAttribute = n != null?n.AtText() : null;

                n = node.ChildOrNull("expandChildren");
                expandChildren = n != null?n.AtText() : null;
            }
        private void Awake()
        {
            Init();

            m_effectiveBoundsType = BoundsType;
            m_filter  = BoundsObject.GetComponent <MeshFilter>();
            m_skinned = BoundsObject.GetComponent <SkinnedMeshRenderer>();

            if (m_filter == null && m_skinned == null)
            {
                m_spriteRenderer = BoundsObject.GetComponent <SpriteRenderer>();
            }

            if (hideFlags != HideFlags.HideAndDontSave)
            {
                if (_Awaked != null)
                {
                    _Awaked(this);
                }
            }
        }
Esempio n. 14
0
        // !!! this is really slow TODO: GS cache with gameobjecttopinfo
        public static bool BoundsComponent(BoundsType boundsType, UnityEngine.GameObject obj, out UnityEngine.Bounds findedBounds, bool onlyFirst)
        {
            bool finded = false;

            findedBounds = new UnityEngine.Bounds();

            System.Type type           = ComponentType(boundsType);
            Component   boundComponent = obj.GetComponent(type);

            if (boundComponent != null)
            {
                switch (boundsType)
                {
                case BoundsType.Sprite:
                    SpriteRenderer spriteRenderer = boundComponent as SpriteRenderer;
                    finded = spriteRenderer != null && spriteRenderer.enabled;
                    if (finded)
                    {
                        findedBounds = spriteRenderer.bounds;
                    }
                    break;

                case BoundsType.Collider:
                    Collider collider = boundComponent as Collider;
                    finded = collider != null && collider.enabled;
                    if (finded)
                    {
                        findedBounds = collider.bounds;
                    }
                    break;

                case BoundsType.Collider2D:
                    BoxCollider2D boxCollider = boundComponent as BoxCollider2D;
                    if (boxCollider)
                    {
                        finded = boxCollider.enabled;
                        if (finded)
                        {
                            Vector3 size   = new Vector3(boxCollider.size.x * obj.transform.lossyScale.x, boxCollider.size.y * obj.transform.lossyScale.y, 0);
                            Vector3 center = boxCollider.center;
                            center      += obj.transform.position;
                            findedBounds = new UnityEngine.Bounds(center, size);
                        }
                    }
                    else
                    {
                        CircleCollider2D circleCollider = boundComponent as CircleCollider2D;
                        if (circleCollider)
                        {
                            finded = circleCollider.enabled;
                            if (finded)
                            {
                                Vector3 size   = new Vector3(circleCollider.radius * obj.transform.lossyScale.x, circleCollider.radius * obj.transform.lossyScale.y, 0);
                                Vector3 center = boxCollider.center;
                                center      += obj.transform.position;
                                findedBounds = new UnityEngine.Bounds(center, size);
                            }
                        }
                        else
                        {
                            Picus.Sys.Debug.Throw("GameObject.BoundsComponent unimplemented 2d collider. Ignoring this collider.", true);
                            finded = false;
                            break;
                        }
                    }
                    break;

                default:
                    throw new System.NotImplementedException();
                }
            }

            int count = obj.transform.childCount;

            for (int i = 0; i < count; i++)
            {
                if (finded && onlyFirst)
                {
                    return(finded);
                }

                UnityEngine.GameObject child = obj.transform.GetChild(i).gameObject;
                UnityEngine.Bounds     childBounds;

                if (BoundsComponent(boundsType, child, out childBounds, onlyFirst))
                {
                    if (finded)
                    {
                        findedBounds.Encapsulate(childBounds);
                    }
                    else
                    {
                        findedBounds = childBounds;
                    }

                    finded = true;
                }
            }

            return(finded);
        }
Esempio n. 15
0
 public Rectangle GetBounds(BoundsType boundsType)
 {
     return(FInternalCOMInterf.GetBounds(boundsType));
 }
 // 変数の範囲を設定する
 public void SetColumnBounds(int index, BoundsType type, double lowerBound, double upperBound)
 {
     GLPK.glp_set_col_bnds(problem, index + 1, (int)type, lowerBound, upperBound);
 }
Esempio n. 17
0
        /// <summary>
        /// Collect the bounds of the indicated types (MeshRenderer and/or Collider) on the object and all of its children, and returns bounds that are a sum of all of those.
        /// </summary>
        /// <param name="go">GameObject to start search from.</param>
        /// <param name="factorIn">The types of bounds to factor in.</param>
        /// <param name="includeChildren">Whether to search all children for bounds.</param>
        /// <returns></returns>
        public static Bounds CollectMyBounds(this GameObject go, BoundsType factorIn, out int numOfBoundsFound, bool includeChildren = true, bool includeInactive = false)
        {
            // if we are ignoring inactive, an inactive parent is already a null. Quit here.
            if (!go.activeInHierarchy && !!includeInactive)
            {
                numOfBoundsFound = 0;
                return(new Bounds());
            }

            bool bothtype = factorIn == BoundsType.Both;
            bool rendtype = bothtype || factorIn == BoundsType.MeshRenderer;
            bool colltype = bothtype || factorIn == BoundsType.Collider;

            // Clear the reusables so they have counts of zero
            meshFilters.Clear();
            meshRenderers.Clear();
            colliders.Clear();
            spriteRenderers.Clear();
            validColliders.Clear();
#if !DISABLE_PHYSICS_2D
            validColliders2D.Clear();
#endif
            int myBoundsCount = 0;

            // Find all of the MeshRenderers and Colliders (as specified)
            if (rendtype)
            {
                if (go.activeInHierarchy)
                {
                    if (includeChildren)
                    {
                        go.GetComponentsInChildren(includeInactive, meshRenderers);
                        go.GetComponentsInChildren(includeInactive, meshFilters);
                        go.GetComponentsInChildren(includeInactive, spriteRenderers);
                    }
                    else
                    {
                        go.GetComponents(meshRenderers);
                        go.GetComponents(meshFilters);
                        go.GetComponents(spriteRenderers);
                    }
                }
            }

            if (colltype)
            {
                if (go.activeInHierarchy)
                {
                    if (includeChildren)
                    {
                        go.GetComponentsInChildren(includeInactive, colliders);
#if !DISABLE_PHYSICS_2D
                        go.GetComponentsInChildren(includeInactive, colliders2D);
#endif
                    }
                    else
                    {
                        go.GetComponents(colliders);
#if !DISABLE_PHYSICS_2D
                        go.GetComponents(colliders2D);
#endif
                    }
                }
            }

            // Add any MeshRenderer attached to the found MeshFilters to their own list.
            // We want the MeshRenderer for its bounds, but only if there is a MeshFilter, otherwise there is a risk of a 0,0,0
            for (int i = 0; i < meshFilters.Count; i++)
            {
                Renderer mr = meshFilters[i].GetComponent <Renderer>();

                if (mr && (mr.enabled || includeInactive))
                {
                    if (!meshRenderers.Contains(mr))
                    {
                        meshRenderers.Add(mr);
                    }
                }
            }

            // Collect only the valid colliders (ignore inactive if not includeInactive)
            for (int i = 0; i < colliders.Count; i++)
            {
                if (colliders[i].enabled || includeInactive)
                {
                    if (colliders[i])
                    {
                        validColliders.Add(colliders[i]);
                    }
                }
            }

#if !DISABLE_PHYSICS_2D
            // Collect only the valid colliders (ignore inactive if not includeInactive)
            for (int i = 0; i < colliders2D.Count; i++)
            {
                if (colliders2D[i] && colliders2D[i].enabled || includeInactive)
                {
                    // 2d colliders arrive as null but present in scene changes, test for null
                    if (colliders2D[i])
                    {
                        validColliders2D.Add(colliders2D[i]);
                    }
                }
            }
#endif
            // Make sure we found some bounds objects, or we need to quit.
            numOfBoundsFound =
                meshRenderers.Count +
                spriteRenderers.Count +
                validColliders.Count
#if !DISABLE_PHYSICS_2D
                + validColliders2D.Count
#endif
            ;
            // No values means no bounds will be found, and this will break things if we try to use it.
            if (numOfBoundsFound == 0)
            {
                return(new Bounds());
            }

            // Get a starting bounds. We need this because the default of centered 0,0,0 will break things if the map is
            // offset and doesn't encapsulte the world origin.
            Bounds compositeBounds;

            if (meshRenderers.Count > 0)
            {
                compositeBounds = meshRenderers[0].bounds;
            }

            else if (validColliders.Count > 0)
            {
                compositeBounds = validColliders[0].bounds;
            }

#if !DISABLE_PHYSICS_2D
            else if (validColliders2D.Count > 0 && validColliders2D[0])
            {
                compositeBounds = validColliders2D[0].bounds;
            }
#endif
            else if (spriteRenderers.Count > 0)
            {
                compositeBounds = spriteRenderers[0].bounds;
            }
            /// nothing found, return an empty bounds
            else
            {
                return(new Bounds());
            }

            for (int i = 0; i < spriteRenderers.Count; i++)
            {
                myBoundsCount++;
                compositeBounds.Encapsulate(spriteRenderers[i].bounds);
            }

            // Encapsulate all outer found bounds into that. We will be adding the root to itself, but no biggy, this only runs once.
            for (int i = 0; i < meshRenderers.Count; i++)
            {
                myBoundsCount++;
                compositeBounds.Encapsulate(meshRenderers[i].bounds);
            }

            for (int i = 0; i < validColliders.Count; i++)
            {
                myBoundsCount++;
                compositeBounds.Encapsulate(validColliders[i].bounds);
            }
#if !DISABLE_PHYSICS_2D
            for (int i = 0; i < validColliders2D.Count; i++)
            {
                myBoundsCount++;
                if (validColliders2D[i])
                {
                    compositeBounds.Encapsulate(validColliders2D[i].bounds);
                }
            }
#endif
            return(compositeBounds);
        }
Esempio n. 18
0
        public static Bounds CollectMyBounds(GameObject go, BoundsType factorIn, bool includeChildren = true)
        {
            int dummy;

            return(CollectMyBounds(go, factorIn, out dummy, includeChildren));
        }
            public Part( NodeReader node )
            {
                name = node.AtText( "name" );
                index = node.AtInteger( "arrayIndex" );
                parent = node.AtInteger( "parentIndex" );
                type = NodeTypeOperator.FromString( node.AtText( "type" ) );
                boundsType = BoundsTypeOperator.FromString( node.AtText( "boundsType" ) );
                inheritType = InheritTypeOperator.FromString( node.AtText( "inheritType" ) );
                //inheritRates
                blendType = AlphaBlendTypeOperator.FromString( node.AtText( "alphaBlendType" ) );
                show = node.AtBoolean( "show" );

                var n = node.ChildOrNull( "expandAttribute" );
                expandAttribute = n != null ? n.AtText() : null;

                n = node.ChildOrNull( "expandChildren" );
                expandChildren = n != null ? n.AtText() : null;
            }
Esempio n. 20
0
 protected virtual void OnBoundsChanged(BoundsType boundsType)
 {
     //            if (BoundsChanged != null)
     //              BoundsChanged(this, boundsType);
 }
Esempio n. 21
0
 public BoundsMessage(XmlDocument patch, BoundsType boundsType) : base(String.Empty, "BOUNDS", String.Empty, patch)
 {
     SetAttribute("type", boundsType.ToString());
 }
Esempio n. 22
0
 public void BoundsChangedCB(BoundsType boundsType)
 {
     FObservedNode.OnBoundsChanged(boundsType);
 }
Esempio n. 23
0
        private static System.Type ComponentType(BoundsType boundsType)
        {
            switch(boundsType)
            {
            case BoundsType.Collider:
                return typeof(Collider);
            case BoundsType.Collider2D:
                return typeof(Collider2D);
            case BoundsType.Sprite:
                return typeof(SpriteRenderer);
            }

            throw new System.NotImplementedException();
        }
Esempio n. 24
0
        /// <summary>
        /// Collect the bounds of the indicated types (MeshRenderer and/or Collider) on the object and all of its children, and returns bounds that are a sum of all of those.
        /// </summary>
        /// <param name="go">GameObject to start search from.</param>
        /// <param name="factorIn">The types of bounds to factor in.</param>
        /// <param name="includeChildren">Whether to search all children for bounds.</param>
        /// <returns></returns>
        public static Bounds CollectMyBounds(GameObject go, BoundsType factorIn, out int numOfBoundsFound, bool includeChildren = true, bool includeInactive = false)
        {
            // if we are ignoring inactive, an inactive parent is already a null. Quit here.
            if (!go.activeInHierarchy && !!includeInactive)
            {
                numOfBoundsFound = 0;
                return(new Bounds());
            }

            bool bothtype = factorIn == BoundsType.Both;
            bool rendtype = bothtype || factorIn == BoundsType.MeshRenderer;
            bool colltype = bothtype || factorIn == BoundsType.Collider;

            // Clear the reusables so they have counts of zero
            reusableSearchMeshFilter.Clear();
            reusableSearchMeshRend.Clear();
            reusableSearchColliders.Clear();
            reusableValidColliders.Clear();

            int myBoundsCount = 0;

            // Find all of the MeshRenderers and Colliders (as specified)
            if (rendtype)
            {
                if (go.activeInHierarchy)
                {
                    if (includeChildren)
                    {
                        go.GetComponentsInChildren(includeInactive, reusableSearchMeshFilter);
                    }
                    else
                    {
                        go.GetComponents(reusableSearchMeshFilter);
                    }
                }
            }

            if (colltype)
            {
                if (go.activeInHierarchy)
                {
                    if (includeChildren)
                    {
                        go.GetComponentsInChildren(includeInactive, reusableSearchColliders);
                    }
                    else
                    {
                        go.GetComponents(reusableSearchColliders);
                    }
                }
            }

            // Add any MeshRenderer attached to the found MeshFilters to their own list.
            // We want the MeshRenderer for its bounds, but only if there is a MeshFilter, otherwise there is a risk of a 0,0,0
            for (int i = 0; i < reusableSearchMeshFilter.Count; i++)
            {
                MeshRenderer mr = reusableSearchMeshFilter[i].GetComponent <MeshRenderer>();

                if (mr && (mr.enabled || includeInactive))
                {
                    reusableSearchMeshRend.Add(mr);
                }
            }

            // Collect only the valid colliders (ignore inactive if not includeInactive)
            for (int i = 0; i < reusableSearchColliders.Count; i++)
            {
                if (reusableSearchColliders[i].enabled || includeInactive)
                {
                    reusableValidColliders.Add(reusableSearchColliders[i]);
                }
            }

            // Make sure we found some bounds objects, or we need to quit.
            numOfBoundsFound = reusableSearchMeshRend.Count + reusableValidColliders.Count;
            // No values means no bounds will be found, and this will break things if we try to use it.
            if (numOfBoundsFound == 0)
            {
                return(new Bounds());
            }

            // Get a starting bounds. We need this because the default of centered 0,0,0 will break things if the map is
            // offset and doesn't encapsulte the world origin.
            Bounds compositeBounds = (reusableSearchMeshRend.Count > 0) ? reusableSearchMeshRend[0].bounds : reusableValidColliders[0].bounds;

            // Encapsulate all outer found bounds into that. We will be adding the root to itself, but no biggy, this only runs once.
            for (int i = 0; i < reusableSearchMeshRend.Count; i++)
            {
                myBoundsCount++;
                compositeBounds.Encapsulate(reusableSearchMeshRend[i].bounds);
            }

            for (int i = 0; i < reusableValidColliders.Count; i++)
            {
                myBoundsCount++;
                compositeBounds.Encapsulate(reusableValidColliders[i].bounds);
            }

            return(compositeBounds);
        }
Esempio n. 25
0
        // !!! this is really slow TODO: GS cache with gameobjecttopinfo
        public static bool BoundsComponent(BoundsType boundsType, UnityEngine.GameObject obj, out UnityEngine.Bounds findedBounds, bool onlyFirst)
        {
            bool finded = false;
            findedBounds = new UnityEngine.Bounds();

            System.Type type = ComponentType(boundsType);
            Component boundComponent = obj.GetComponent(type);

            if (boundComponent != null)
            {
                switch (boundsType)
                {
                case BoundsType.Sprite:
                    SpriteRenderer spriteRenderer = boundComponent as SpriteRenderer;
                    finded = spriteRenderer != null && spriteRenderer.enabled;
                    if (finded)
                        findedBounds = spriteRenderer.bounds;
                    break;
                case BoundsType.Collider:
                    Collider collider = boundComponent as Collider;
                    finded = collider != null && collider.enabled;
                    if (finded)
                        findedBounds = collider.bounds;
                    break;
                case BoundsType.Collider2D:
                    BoxCollider2D boxCollider = boundComponent as BoxCollider2D;
                    if (boxCollider)
                    {
                        finded = boxCollider.enabled;
                        if (finded)
                        {
                            Vector3 size = new Vector3(boxCollider.size.x * obj.transform.lossyScale.x, boxCollider.size.y * obj.transform.lossyScale.y, 0);
                            Vector3 center = boxCollider.center;
                            center += obj.transform.position;
                            findedBounds = new UnityEngine.Bounds(center, size);
                        }
                    }
                    else
                    {
                        CircleCollider2D circleCollider = boundComponent as CircleCollider2D;
                        if (circleCollider)
                        {
                            finded = circleCollider.enabled;
                            if (finded)
                            {
                                Vector3 size = new Vector3(circleCollider.radius * obj.transform.lossyScale.x, circleCollider.radius * obj.transform.lossyScale.y, 0);
                                Vector3 center = boxCollider.center;
                                center += obj.transform.position;
                                findedBounds = new UnityEngine.Bounds(center, size);
                            }
                        }
                        else
                        {
                            Picus.Sys.Debug.Throw("GameObject.BoundsComponent unimplemented 2d collider. Ignoring this collider.", true);
                            finded = false;
                            break;
                        }
                    }
                    break;
                default:
                    throw new System.NotImplementedException();
                }
            }

            int count = obj.transform.childCount;
            for(int i = 0; i < count; i++)
            {
                if (finded && onlyFirst) return finded;

                UnityEngine.GameObject child = obj.transform.GetChild(i).gameObject;
                UnityEngine.Bounds childBounds;

                if (BoundsComponent(boundsType, child, out childBounds, onlyFirst))
                {
                    if (finded)
                        findedBounds.Encapsulate(childBounds);
                    else
                        findedBounds = childBounds;

                    finded = true;
                }
            }

            return finded;
        }
Esempio n. 26
0
 public BoundsChangedEventArgs(BoundsType boundsType)
 {
     this.boundsType = boundsType;
 }