public void In( [FriendlyName("Target", "The GameObject to use as the new AudioListener.")] GameObject Target ) { AudioListener targetListener; targetListener = Target.GetComponent <AudioListener>(); if (targetListener != null) { try { AudioListener[] listenerList = ScriptableObject.FindObjectsOfType(typeof(AudioListener)) as AudioListener[]; foreach (AudioListener tmpListener in listenerList) { tmpListener.enabled = false; } targetListener.enabled = true; } catch (System.Exception e) { uScriptDebug.Log((e.ToString()), uScriptDebug.Type.Error); } } }
public void In( [FriendlyName("From", "The GameObject containing the camera to switch from.")] GameObject FromCamera, [FriendlyName("To", "The GameObject containing the camera to switch to.")] GameObject Target, [FriendlyName("Enable AudioListener", "Whether or not to enable the 'To' camera's AudioListener component (if it has one).")] [DefaultValue(true), SocketState(false, false)] bool EnableAudioListener ) { if (FromCamera != null && Target != null) { try { Component FromCam = FromCamera.GetComponent("Camera"); Component ToCam = Target.GetComponent("Camera"); #if (UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7) FromCam.camera.enabled = false; ToCam.camera.enabled = true; #else FromCam.GetComponent <Camera>().enabled = false; ToCam.GetComponent <Camera>().enabled = true; #endif } catch (System.Exception e) { uScriptDebug.Log((e.ToString()), uScriptDebug.Type.Error); } if (EnableAudioListener) { AudioListener toListener; toListener = Target.GetComponent <AudioListener>(); if (toListener != null) { try { AudioListener[] listenerList = ScriptableObject.FindObjectsOfType(typeof(AudioListener)) as AudioListener[]; foreach (AudioListener tmpListener in listenerList) { tmpListener.enabled = false; } toListener.enabled = true; } catch (System.Exception e) { uScriptDebug.Log((e.ToString()), uScriptDebug.Type.Error); } } } } }
// Use this for initialization void Start() { exps = ScriptableObject.FindObjectsOfType <Explosion>(); List_Explosion = new List <Explosion>(); debris = new List <GameObject>(); foreach (Explosion exp in exps) { List_Explosion.Add(exp); } }
/// <summary>Find an Element with the following Name</summary> public static CGElement Find(string Name) { foreach (CGElement element in ScriptableObject.FindObjectsOfType(typeof(CGElement))) { if (element.name == Name) { return(element); } } return(null); }
// Update is called once per frame void Update() { Debug.Log(debris.Count); for (; debris.Count > 100;) { Destroy(debris[0].gameObject); debris.RemoveAt(0); } blasts = ScriptableObject.FindObjectsOfType <Blast>(); if (List_Explosion.Count > 0) { Debug.Log(List_Explosion.Count); for (int i = 0; i < List_Explosion.Count; i++) { if (List_Explosion[i].explosed) { if (List_Explosion[i].LifeTime > 0) { foreach (Blast bl in blasts) { bl.gameObject.GetComponent <Rigidbody>().AddExplosionForce(200, List_Explosion[i].transform.position, 10); } List_Explosion[i].LifeTime--; } else { Destroy(List_Explosion[i].gameObject); List_Explosion.RemoveAt(i); } } } } if (Input.GetMouseButtonDown(0)) { GameObject bom = Instantiate((GameObject)Resources.Load("bom"), transform.position, Quaternion.identity); List_Explosion.Add(bom.GetComponent <Explosion>()); } }