コード例 #1
0
    private void SetupLevel(Transform[] trs)
    {
        try
        {

            var level = new GameObject("level").transform;

            foreach (var a in FindObjectsOfType<Transform>().Where(b => trs.All(a => a != b)))
            {
                if (a.parent == null)
                    a.parent = level;
                if (a.gameObject.layer > 7 || a.gameObject.layer == 0)
                    a.gameObject.layer = Layer.level;
                a.gameObject.tag = "Untagged";


                if (a.rigidbody || a.light && a.light.type == LightType.Directional || a.camera || a.name.ToLower() == "collision_wall")
                    Destroy(a.gameObject);
                if (a.GetComponent<Terrain>())
                {
                    a.gameObject.layer = Layer.terrain;
                    a.gameObject.name = "Terrain";
                    //terrain = a.GetComponent<Terrain>();
                }
                //else if (a.childCount == 0 && a.collider && (!a.renderer || !a.renderer.enabled) && !a.GetComponent<Terrain>())
                //    Destroy(a.gameObject);

                //foreach (var b in a.GetComponentsInChildren<Collider>())
                //    b.sharedMaterial = ph;


            }
            //foreach (var a in FindObjectsOfType<Camera>())
            //    Destroy(a.gameObject);
        }
        catch (Exception e)
        {
            Debug.LogError(e);
        }
    }