コード例 #1
0
        private void AddManagers(GameObject go, GameObject root)
        {
            // Replace materials for this object
            MaterialSwapper.ReplaceMaterialsForGameObject(go);

            // Add a tube light manager if there are tube light descriptors
            if (go.GetComponentInChildren <TubeLight>(true) != null)
            {
                TubeLightManager tlm = root.GetComponent <TubeLightManager>();
                if (tlm == null)
                {
                    tlm = root.AddComponent <TubeLightManager>();
                }
                tlm.CreateTubeLights(go);
            }

            // Rotation effect manager
            if (go.GetComponentInChildren <RotationEventEffect>(true) != null)
            {
                RotationEventEffectManager rotManager = root.GetComponent <RotationEventEffectManager>();
                if (rotManager == null)
                {
                    rotManager = root.AddComponent <RotationEventEffectManager>();
                }
                rotManager.CreateEffects(go);
            }

            // Add a trackRing controller if there are track ring descriptors
            if (go.GetComponentInChildren <TrackRings>(true) != null)
            {
                foreach (TrackRings trackRings in go.GetComponentsInChildren <TrackRings>(true))
                {
                    GameObject ringPrefab = trackRings.trackLaneRingPrefab;

                    // Add managers to prefabs (nesting)
                    AddManagers(ringPrefab, root);
                }

                TrackRingsManagerSpawner trms = root.GetComponent <TrackRingsManagerSpawner>();
                if (trms == null)
                {
                    trms = root.AddComponent <TrackRingsManagerSpawner>();
                }
                trms.CreateTrackRings(go);
            }

            // Add spectrogram manager
            if (go.GetComponentInChildren <Spectrogram>(true) != null)
            {
                foreach (Spectrogram spec in go.GetComponentsInChildren <Spectrogram>(true))
                {
                    GameObject colPrefab = spec.columnPrefab;
                    AddManagers(colPrefab, root);
                }

                SpectrogramColumnManager specManager = go.GetComponent <SpectrogramColumnManager>();
                if (specManager == null)
                {
                    specManager = go.AddComponent <SpectrogramColumnManager>();
                }
                specManager.CreateColumns(go);
            }

            if (go.GetComponentInChildren <SpectrogramMaterial>(true) != null)
            {
                // Add spectrogram materials manager
                SpectrogramMaterialManager specMatManager = go.GetComponent <SpectrogramMaterialManager>();
                if (specMatManager == null)
                {
                    specMatManager = go.AddComponent <SpectrogramMaterialManager>();
                }
                specMatManager.UpdateMaterials();
            }


            if (go.GetComponentInChildren <SpectrogramAnimationState>(true) != null)
            {
                // Add spectrogram animation state manager
                SpectrogramAnimationStateManager specAnimManager = go.GetComponent <SpectrogramAnimationStateManager>();
                if (specAnimManager == null)
                {
                    specAnimManager = go.AddComponent <SpectrogramAnimationStateManager>();
                }
                specAnimManager.UpdateAnimationStates();
            }

            // Add Song event manager
            if (go.GetComponentInChildren <SongEventHandler>(true) != null)
            {
                foreach (SongEventHandler handler in go.GetComponentsInChildren <SongEventHandler>())
                {
                    SongEventManager manager = handler.gameObject.AddComponent <SongEventManager>();
                    manager._songEventHandler = handler;
                }
            }

            // Add EventManager
            if (go.GetComponentInChildren <EventManager>(true) != null)
            {
                foreach (EventManager em in go.GetComponentsInChildren <EventManager>())
                {
                    PlatformEventManager pem = em.gameObject.AddComponent <PlatformEventManager>();
                    pem._EventManager = em;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Recursively attaches managers to a <see cref="CustomPlatform"/>
        /// </summary>
        /// <param name="go">The current <see cref="GameObject"/>, this parameter acts as a pointer</param>
        /// <param name="root">The root <see cref="GameObject"/> of the <see cref="CustomPlatform"/></param>
        private void AddManagers(GameObject go, GameObject root)
        {
            // Rotation effect manager
            if (go.GetComponentInChildren <RotationEventEffect>(true) != null || go.GetComponentInChildren <PairRotationEventEffect>(true) != null)
            {
                RotationEventEffectManager rotManager = go.GetComponent <RotationEventEffectManager>();
                if (rotManager == null)
                {
                    rotManager = _container.InstantiateComponent <RotationEventEffectManager>(go);
                    PlatformManager.SpawnedComponents.Add(rotManager);
                    rotManager.CreateEffects(go);
                }
            }

            // Add a trackRing controller if there are track ring descriptors
            if (go.GetComponentInChildren <TrackRings>(true) != null)
            {
                foreach (TrackRings trackRings in go.GetComponentsInChildren <TrackRings>(true))
                {
                    GameObject ringPrefab = trackRings.trackLaneRingPrefab;

                    // Add managers to prefabs (nesting)
                    AddManagers(ringPrefab, root);
                }

                TrackRingsManagerSpawner trms = go.GetComponent <TrackRingsManagerSpawner>();
                if (trms == null)
                {
                    trms = _container.InstantiateComponent <TrackRingsManagerSpawner>(go);
                    PlatformManager.SpawnedComponents.Add(trms);
                }
                trms.CreateTrackRings(go);
            }

            // Add spectrogram manager
            if (go.GetComponentInChildren <Spectrogram>(true) != null)
            {
                foreach (Spectrogram spec in go.GetComponentsInChildren <Spectrogram>(true))
                {
                    GameObject colPrefab = spec.columnPrefab;
                    AddManagers(colPrefab, root);
                }

                SpectrogramColumnManager specManager = go.GetComponent <SpectrogramColumnManager>();
                if (specManager == null)
                {
                    specManager = _container.InstantiateComponent <SpectrogramColumnManager>(go);
                    PlatformManager.SpawnedComponents.Add(specManager);
                }
                specManager.CreateColumns(go);
            }

            if (go.GetComponentInChildren <SpectrogramMaterial>(true) != null)
            {
                // Add spectrogram materials manager
                SpectrogramMaterialManager specMatManager = go.GetComponent <SpectrogramMaterialManager>();
                if (specMatManager == null)
                {
                    specMatManager = _container.InstantiateComponent <SpectrogramMaterialManager>(go);
                    PlatformManager.SpawnedComponents.Add(specMatManager);
                }
                specMatManager.UpdateMaterials(go);
            }

            if (go.GetComponentInChildren <SpectrogramAnimationState>(true) != null)
            {
                // Add spectrogram animation state manager
                SpectrogramAnimationStateManager specAnimManager = go.GetComponent <SpectrogramAnimationStateManager>();
                if (specAnimManager == null)
                {
                    specAnimManager = _container.InstantiateComponent <SpectrogramAnimationStateManager>(go);
                    PlatformManager.SpawnedComponents.Add(specAnimManager);
                }
                specAnimManager.UpdateAnimationStates();
            }

            if (go.GetComponentInChildren <ColorMaterial>(true) != null)
            {
                // Add color materials manager
                ColorMaterialManager colMatManager = go.GetComponent <ColorMaterialManager>();
                if (colMatManager == null)
                {
                    colMatManager = _container.InstantiateComponent <ColorMaterialManager>(go);
                    PlatformManager.SpawnedComponents.Add(colMatManager);
                }
                colMatManager.UpdateMaterials(go);
            }

            // Add Song event manager
            if (go.GetComponentInChildren <SongEventHandler>(true) != null)
            {
                foreach (SongEventHandler handler in go.GetComponentsInChildren <SongEventHandler>())
                {
                    SongEventManager manager = _container.InstantiateComponent <SongEventManager>(handler.gameObject);
                    PlatformManager.SpawnedComponents.Add(manager);
                    manager._songEventHandler = handler;
                }
            }

            // Add EventManager
            if (go.GetComponentInChildren <EventManager>(true) != null)
            {
                foreach (EventManager em in go.GetComponentsInChildren <EventManager>())
                {
                    PlatformEventManager pem = _container.InstantiateComponent <PlatformEventManager>(em.gameObject);
                    PlatformManager.SpawnedComponents.Add(pem);
                    pem._eventManager = em;
                }
            }
        }