public override void OnInspectorGUI() { // Cast target to an ExplosionMat ExplosionMat mat = (ExplosionMat)target; serializedObject.Update(); // Always call this EditorGUIUtility.labelWidth = 0; EditorGUIUtility.fieldWidth = 0; // Check if any changes are made to the GUI EditorGUI.BeginChangeCheck(); EditorGUILayout.Slider(alpha, 0, 1, new GUIContent("Alpha")); EditorGUILayout.PropertyField(heat, new GUIContent("Heat")); EditorGUILayout.PropertyField(scrollSpeed, new GUIContent("Noise Scroll Speed")); EditorGUILayout.PropertyField(frequency, new GUIContent("Noise Frequency")); EditorGUILayout.PropertyField(scattering, new GUIContent("Scattering")); EditorGUILayout.IntPopup(quality, qualityStrings, qualityNums, new GUIContent("Quality")); EditorGUILayout.IntPopup(octaves, octaveStrings, octaveNums, new GUIContent("Octaves")); if (advanced = EditorGUILayout.Foldout(advanced, "Advanced")) { EditorGUILayout.PropertyField(ramp, new GUIContent("Ramp Texture")); EditorGUILayout.PropertyField(noise, new GUIContent("Noise Texture")); } serializedObject.ApplyModifiedProperties(); // Always call this //Make shader update properties if editor has been changed if (EditorGUI.EndChangeCheck() || Event.current.commandName == "UndoRedoPerformed") { // Tell the ExplosionMat to update the shader properties mat.UpdateShaderProperties(); } }
void Start() { player = FindObjectOfType <Ball>().gameObject; explosionMat = GetComponent <ExplosionMat>(); explosionMat._alpha = 0f; SetSpawnPoint(); StartCoroutine(Shoot()); }
void Start() { _explosionMaterial = GetComponent <ExplosionMat>(); _explosionMaterial._alpha = DEFAULT_ALPHA; _explosionMaterial._heat = (Random.value * .5f) + .8f; _duration = Random.value * STANDARD_EXPLOSION_DURATION / 2.0f + STANDARD_EXPLOSION_DURATION; _startTime = Time.time; }
internal void explode() { explosionInstance = Instantiate(explosion); explosionInstance._alpha = 0; explosionInstance.transform.position = transform.position; spriteRenderer.enabled = false; iTween.ValueTo(gameObject, iTween.Hash( "from", 1, "to", 0, "time", 2, "easetype", iTween.EaseType.easeOutSine, "onupdate", "updateExplosionAlpha", "oncomplete", "explosionKill" )); }
IEnumerator Explosion() { float stepVal = .05f; GameObject exp = Instantiate(explosion, transform.position, transform.rotation) as GameObject; // MeshRenderer mr = exp.GetComponent<MeshRenderer>() as MeshRenderer; // Debug.Log("meshrenderer shared material is: " + mr.sharedMaterial.ToString()); ExplosionMat expmat = exp.GetComponent <ExplosionMat>(); // float tempalpha = expmat._alpha; explosionAudio.Play(); while (expmat._alpha > 0) { // Debug.Log(expmat._alpha); // float tempcolor = exp.GetComponent<Renderer>().material.color.a; expmat.SetAlpha(Mathf.MoveTowards(expmat._alpha, 0, stepVal)); // exp.GetComponent<Renderer>().material.color = tempcolor; yield return(null); } // transform.gameObject.SetActive(false); Destroy(transform.gameObject, .01f); Destroy(exp, .1f); }