GetRenderableCenterRecurse() public static method

public static GetRenderableCenterRecurse ( GameObject go, int minDepth, int maxDepth ) : Vector3
go UnityEngine.GameObject
minDepth int
maxDepth int
return Vector3
コード例 #1
0
        public static Vector3 GetRenderableCenterRecurse(GameObject go, int minDepth, int maxDepth)
        {
            Vector3 zero = Vector3.zero;
            float   renderableCenterRecurse = GameObjectInspector.GetRenderableCenterRecurse(ref zero, go, 0, minDepth, maxDepth);

            return((double)renderableCenterRecurse <= 0.0 ? go.transform.position : zero / renderableCenterRecurse);
        }
コード例 #2
0
        private static float GetRenderableCenterRecurse(ref Vector3 center, GameObject go, int depth, int minDepth, int maxDepth)
        {
            if (depth > maxDepth)
            {
                return(0f);
            }
            float num = 0f;

            if (depth > minDepth)
            {
                MeshRenderer        meshRenderer        = go.GetComponent(typeof(MeshRenderer)) as MeshRenderer;
                MeshFilter          x                   = go.GetComponent(typeof(MeshFilter)) as MeshFilter;
                SkinnedMeshRenderer skinnedMeshRenderer = go.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
                SpriteRenderer      spriteRenderer      = go.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;
                if (meshRenderer == null && x == null && skinnedMeshRenderer == null && spriteRenderer == null)
                {
                    num     = 1f;
                    center += go.transform.position;
                }
                else
                {
                    if (meshRenderer != null && x != null)
                    {
                        if (Vector3.Distance(meshRenderer.bounds.center, go.transform.position) < 0.01f)
                        {
                            num     = 1f;
                            center += go.transform.position;
                        }
                    }
                    else
                    {
                        if (skinnedMeshRenderer != null)
                        {
                            if (Vector3.Distance(skinnedMeshRenderer.bounds.center, go.transform.position) < 0.01f)
                            {
                                num     = 1f;
                                center += go.transform.position;
                            }
                        }
                        else
                        {
                            if (spriteRenderer != null && Vector3.Distance(spriteRenderer.bounds.center, go.transform.position) < 0.01f)
                            {
                                num     = 1f;
                                center += go.transform.position;
                            }
                        }
                    }
                }
            }
            depth++;
            foreach (Transform transform in go.transform)
            {
                num += GameObjectInspector.GetRenderableCenterRecurse(ref center, transform.gameObject, depth, minDepth, maxDepth);
            }
            return(num);
        }
コード例 #3
0
        public static Vector3 GetRenderableCenterRecurse(GameObject go, int minDepth, int maxDepth)
        {
            Vector3 vector = Vector3.zero;
            float   renderableCenterRecurse = GameObjectInspector.GetRenderableCenterRecurse(ref vector, go, 0, minDepth, maxDepth);

            if (renderableCenterRecurse > 0f)
            {
                vector /= renderableCenterRecurse;
            }
            else
            {
                vector = go.transform.position;
            }
            return(vector);
        }
コード例 #4
0
        private static float GetRenderableCenterRecurse(ref Vector3 center, GameObject go, int depth, int minDepth, int maxDepth)
        {
            if (depth > maxDepth)
            {
                return(0.0f);
            }
            float num = 0.0f;

            if (depth > minDepth)
            {
                MeshRenderer        component1 = go.GetComponent(typeof(MeshRenderer)) as MeshRenderer;
                MeshFilter          component2 = go.GetComponent(typeof(MeshFilter)) as MeshFilter;
                SkinnedMeshRenderer component3 = go.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
                SpriteRenderer      component4 = go.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;
                if ((UnityEngine.Object)component1 == (UnityEngine.Object)null && (UnityEngine.Object)component2 == (UnityEngine.Object)null && ((UnityEngine.Object)component3 == (UnityEngine.Object)null && (UnityEngine.Object)component4 == (UnityEngine.Object)null))
                {
                    num    = 1f;
                    center = center + go.transform.position;
                }
                else if ((UnityEngine.Object)component1 != (UnityEngine.Object)null && (UnityEngine.Object)component2 != (UnityEngine.Object)null)
                {
                    if ((double)Vector3.Distance(component1.bounds.center, go.transform.position) < 0.00999999977648258)
                    {
                        num    = 1f;
                        center = center + go.transform.position;
                    }
                }
                else if ((UnityEngine.Object)component3 != (UnityEngine.Object)null)
                {
                    if ((double)Vector3.Distance(component3.bounds.center, go.transform.position) < 0.00999999977648258)
                    {
                        num    = 1f;
                        center = center + go.transform.position;
                    }
                }
                else if ((UnityEngine.Object)component4 != (UnityEngine.Object)null && (double)Vector3.Distance(component4.bounds.center, go.transform.position) < 0.00999999977648258)
                {
                    num    = 1f;
                    center = center + go.transform.position;
                }
            }
            ++depth;
            foreach (Transform transform in go.transform)
            {
                num += GameObjectInspector.GetRenderableCenterRecurse(ref center, transform.gameObject, depth, minDepth, maxDepth);
            }
            return(num);
        }
コード例 #5
0
        private static float GetRenderableCenterRecurse(ref Vector3 center, GameObject go, int depth, int minDepth, int maxDepth)
        {
            float result;

            if (depth > maxDepth)
            {
                result = 0f;
            }
            else
            {
                float num = 0f;
                if (depth > minDepth)
                {
                    MeshRenderer        meshRenderer        = go.GetComponent(typeof(MeshRenderer)) as MeshRenderer;
                    MeshFilter          x                   = go.GetComponent(typeof(MeshFilter)) as MeshFilter;
                    SkinnedMeshRenderer skinnedMeshRenderer = go.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
                    SpriteRenderer      spriteRenderer      = go.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;
                    if (meshRenderer == null && x == null && skinnedMeshRenderer == null && spriteRenderer == null)
                    {
                        num     = 1f;
                        center += go.transform.position;
                    }
                    else if (meshRenderer != null && x != null)
                    {
                        if (Vector3.Distance(meshRenderer.bounds.center, go.transform.position) < 0.01f)
                        {
                            num     = 1f;
                            center += go.transform.position;
                        }
                    }
                    else if (skinnedMeshRenderer != null)
                    {
                        if (Vector3.Distance(skinnedMeshRenderer.bounds.center, go.transform.position) < 0.01f)
                        {
                            num     = 1f;
                            center += go.transform.position;
                        }
                    }
                    else if (spriteRenderer != null)
                    {
                        if (Vector3.Distance(spriteRenderer.bounds.center, go.transform.position) < 0.01f)
                        {
                            num     = 1f;
                            center += go.transform.position;
                        }
                    }
                }
                depth++;
                IEnumerator enumerator = go.transform.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        Transform transform = (Transform)enumerator.Current;
                        num += GameObjectInspector.GetRenderableCenterRecurse(ref center, transform.gameObject, depth, minDepth, maxDepth);
                    }
                }
                finally
                {
                    IDisposable disposable;
                    if ((disposable = (enumerator as IDisposable)) != null)
                    {
                        disposable.Dispose();
                    }
                }
                result = num;
            }
            return(result);
        }