UnityEngine.InternalStaticBatchingUtility.CombineGameObjects C# (CSharp) Method

CombineGameObjects() public static method

public static CombineGameObjects ( GameObject gos, GameObject staticBatchRoot, bool isEditorPostprocessScene ) : void
gos GameObject
staticBatchRoot GameObject
isEditorPostprocessScene bool
return void
        public static void CombineGameObjects(GameObject[] gos, GameObject staticBatchRoot, bool isEditorPostprocessScene)
        {
            Matrix4x4 identity = Matrix4x4.identity;
            Transform staticBatchRootTransform = null;
            if (staticBatchRoot != null)
            {
                identity = staticBatchRoot.transform.worldToLocalMatrix;
                staticBatchRootTransform = staticBatchRoot.transform;
            }
            int batchIndex = 0;
            int num2 = 0;
            List<MeshSubsetCombineUtility.MeshContainer> meshes = new List<MeshSubsetCombineUtility.MeshContainer>();
            Array.Sort(gos, new SortGO());
            foreach (GameObject obj2 in gos)
            {
                MeshFilter component = obj2.GetComponent(typeof(MeshFilter)) as MeshFilter;
                if (component != null)
                {
                    Mesh sharedMesh = component.sharedMesh;
                    if ((sharedMesh != null) && (isEditorPostprocessScene || sharedMesh.canAccess))
                    {
                        Renderer context = component.GetComponent<Renderer>();
                        if (((context != null) && context.enabled) && (context.staticBatchIndex == 0))
                        {
                            Material[] sharedMaterials = context.sharedMaterials;
                            if (<>f__am$cache0 == null)
                            {
                                <>f__am$cache0 = new Func<Material, bool>(null, (IntPtr) <CombineGameObjects>m__0);

Usage Example

コード例 #1
0
        public static void Combine(GameObject staticBatchRoot, bool combineOnlyStatic, bool isEditorPostprocessScene)
        {
            GameObject[]      objectsOfType  = (GameObject[])Object.FindObjectsOfType(typeof(GameObject));
            List <GameObject> gameObjectList = new List <GameObject>();

            foreach (GameObject gameObject in objectsOfType)
            {
                if ((!((Object)staticBatchRoot != (Object)null) || gameObject.transform.IsChildOf(staticBatchRoot.transform)) && (!combineOnlyStatic || gameObject.isStaticBatchable))
                {
                    gameObjectList.Add(gameObject);
                }
            }
            InternalStaticBatchingUtility.CombineGameObjects(gameObjectList.ToArray(), staticBatchRoot, isEditorPostprocessScene);
        }
All Usage Examples Of UnityEngine.InternalStaticBatchingUtility::CombineGameObjects
InternalStaticBatchingUtility