示例#1
0
        private void Start()
        {
            _audioListener = (AudioListener)UnityEngine.Object.FindObjectOfType(typeof(AudioListener));
            VolumeMeter component = base.gameObject.GetComponent <VolumeMeter>();

            if (component != null)
            {
                component.CollectAudioComponents();
            }
        }
示例#2
0
 public void LoadAsset(string prefabName, string destinationComponent)
 {
     if (_globalComponentTable.ContainsKey(destinationComponent))
     {
         Component          component = _globalComponentTable[destinationComponent];
         UnityEngine.Object @object   = Resources.Load(prefabName);
         if (@object != null)
         {
             GameObject gameObject = UnityEngine.Object.Instantiate(@object) as GameObject;
             gameObject.name = gameObject.name.Replace("(Clone)", "");
             string key = destinationComponent + "_" + gameObject.name;
             if (_globalComponentTable.ContainsKey(key))
             {
                 UnityEngine.Object.Destroy(gameObject);
                 return;
             }
             gameObject.transform.parent = component.transform;
             Component component2 = gameObject.GetComponent <Component>();
             if (component2 != null)
             {
                 component2.Initialise(component, isComponentInstance: false);
                 component.AddComponent(component2);
                 AddChildComponentsToGlobalTable(component2, destinationComponent);
             }
             VolumeMeter component3 = component.GetComponent <VolumeMeter>();
             if (component3 != null)
             {
                 component3.CollectAudioComponents();
             }
             DebugLog.Print("Asset [" + prefabName + "] loaded succesfuly");
         }
         else
         {
             DebugLog.Print("Asset [" + prefabName + "] name not found", DebugLevel.Error);
         }
     }
     else
     {
         DebugLog.Print("Target Component [" + destinationComponent + "] not found", DebugLevel.Error);
     }
 }
示例#3
0
 public void LoadAsset(GameObject component, string destinationComponent)
 {
     if (_globalComponentTable.ContainsKey(destinationComponent))
     {
         Component component2 = _globalComponentTable[destinationComponent];
         if (component != null)
         {
             component.name = component.name.Replace("(Clone)", "");
             string key = destinationComponent + "_" + component.name;
             if (_globalComponentTable.ContainsKey(key))
             {
                 UnityEngine.Object.DestroyImmediate(component);
                 return;
             }
             component.transform.parent = component2.transform;
             Component component3 = component.GetComponent <Component>();
             if (component3 != null)
             {
                 component3.Initialise(component2, isComponentInstance: false);
                 component2.AddComponent(component3);
                 AddChildComponentsToGlobalTable(component3, destinationComponent);
                 VolumeMeter component4 = component2.GetComponent <VolumeMeter>();
                 if (component4 != null)
                 {
                     component4.CollectAudioComponents();
                 }
             }
             DebugLog.Print("Asset [" + component.name + "] loaded succesfuly");
         }
         else
         {
             DebugLog.Print("Asset [" + component.name + "] name not found", DebugLevel.Error);
         }
     }
     else
     {
         DebugLog.Print("Target Component [" + destinationComponent + "] not found", DebugLevel.Error);
     }
 }
示例#4
0
        public bool RegisterGroupComponent(GroupComponent groupComponent, string targetGroupComponentPath, bool createProxy = true)
        {
            if (!_allowExternalGroupComponents)
            {
                DebugLog.Print("External GroupComponent registration is disabled");
                return(false);
            }
            bool      result          = false;
            Component componentByName = GetComponentByName(targetGroupComponentPath);

            if (groupComponent != null)
            {
                groupComponent.Initialise(componentByName, isComponentInstance: false);
                if (componentByName != null)
                {
                    componentByName.AddComponent(groupComponent);
                }
                else
                {
                    _components.Add(groupComponent);
                }
                if (createProxy)
                {
                    GameObject gameObject = new GameObject();
                    gameObject.hideFlags = HideFlags.DontSave;
                    GroupComponentProxy groupComponentProxy = gameObject.AddComponent <GroupComponentProxy>();
                    groupComponentProxy._groupComponent = groupComponent;
                    groupComponentProxy.name            = groupComponent.name + "_Proxy";
                    if (componentByName != null)
                    {
                        groupComponentProxy.transform.parent = componentByName.transform;
                    }
                    else
                    {
                        groupComponentProxy.transform.parent = base.gameObject.transform;
                    }
                    _groupComponentProxies.Add(groupComponentProxy);
                }
                else if (componentByName != null)
                {
                    groupComponent.transform.parent = componentByName.transform;
                }
                else
                {
                    groupComponent.transform.parent = base.gameObject.transform;
                }
                if (componentByName != null)
                {
                    VolumeMeter component = componentByName.GetComponent <VolumeMeter>();
                    if (component != null)
                    {
                        component.CollectAudioComponents();
                    }
                }
                DebugLog.Print("GroupComponent [" + groupComponent.name + "] registred succesfuly");
                result = true;
            }
            else
            {
                DebugLog.Print("GroupComponent [" + groupComponent.name + "] failed to register", DebugLevel.Error);
            }
            return(result);
        }