public override void OnInspectorGUI() { DrawDefaultInspector(); if (GUILayout.Button("Shake Object")) { ObjectShaker objectShaker = (ObjectShaker)target; objectShaker.ShakeForDuration(1.0f); } }
private void Start() { currentTime = offsetTime; shaker = transform.Find("Material").GetComponent <ObjectShaker>(); rend = shaker.GetComponent <Renderer>(); coll = transform.Find("Collider").GetComponent <Collider>(); audioSource = gameObject.AddComponent <AudioSource>(); if (toggleClip == null) { toggleClip = GameObject.FindGameObjectWithTag("Player").GetComponent <SoundController>().toggle; } audioSource.loop = false; audioSource.spatialBlend = 1; audioSource.maxDistance = 12; audioSource.minDistance = 2.5f; audioSource.rolloffMode = AudioRolloffMode.Linear; audioSource.clip = toggleClip; }
private void Start() { shaker = transform.Find("MatParent/Material").GetComponent <ObjectShaker>(); mat = shaker.GetComponent <Renderer>().material; originalColor = mat.GetColor("_Color"); animator = transform.parent.GetComponent <Animator>(); audioSource = gameObject.AddComponent <AudioSource>(); if (crumbleClip == null) { crumbleClip = GameObject.FindGameObjectWithTag("Player").GetComponent <SoundController>().crumble; } if (crumbleLiteClip == null) { crumbleLiteClip = GameObject.FindGameObjectWithTag("Player").GetComponent <SoundController>().crumbleLite; } audioSource.loop = false; audioSource.spatialBlend = 1; audioSource.maxDistance = 12; audioSource.minDistance = 2.5f; audioSource.rolloffMode = AudioRolloffMode.Linear; }