internal void Init(float decalLifeTime, float decalStartFadeTime, Material decalMaterial) { decal = GetComponent <DeferredDecal>(); decal.m_Material = decalMaterial; this.decalLifeTime = decalLifeTime; this.decalStartFadeTime = decalStartFadeTime; }
public void RemoveDecal(DeferredDecal d) { m_Decals.Remove(d); }
// Here is where the magic begins! You can use any GUI command here (As far as i know) public override void OnInspectorGUI() { GUILayout.BeginVertical(); GUILayout.Label("The splatter script", EditorStyles.boldLabel); _target.randomVelocityFactor = EditorGUILayout.FloatField("Spread of the particles", _target.randomVelocityFactor); _target.impactForce = EditorGUILayout.FloatField("The force the particle uses", _target.impactForce); _target.maxDecals = EditorGUILayout.IntField("How many particles wil spawn", _target.maxDecals); _target.particleLifeTime = EditorGUILayout.FloatField("Time until splatter is destroyed", _target.particleLifeTime); _target.reflectImpact = EditorGUILayout.Toggle("Reflect object on hit", _target.reflectImpact); if (_target.reflectImpact) { _target.reflectStrength = EditorGUILayout.Slider("Amount of reflection", _target.reflectStrength, 0f, 1f); } _target.particleToUse = (GameObject)EditorGUILayout.ObjectField("Splatter to be used", _target.particleToUse, typeof(GameObject), true); if (_target.particleToUse == null) { EditorGUILayout.HelpBox("You need to assign a particle you want to use!", MessageType.Error); } else { _target.minSplaterSize = EditorGUILayout.FloatField("Minimum particle size", _target.minSplaterSize); _target.maxSplaterSize = EditorGUILayout.FloatField("Maximum particle size", _target.maxSplaterSize); try { DeferredDecal deferredDecal = (DeferredDecal)EditorGUILayout.ObjectField("Decal to be used", _target.decal, typeof(DeferredDecal), false); _target.decal = deferredDecal == null ? null : deferredDecal.gameObject; } catch (InvalidCastException e) {} _target.decalMaterial = (Material)EditorGUILayout.ObjectField("Override decal material", _target.decalMaterial, typeof(Material), true); if (_target.decalMaterial == null) { EditorGUILayout.HelpBox("You need to assign a decal material you want to use!", MessageType.Error); } else { _target.randomYRotation = EditorGUILayout.Toggle("Random Y rotation for decal", _target.randomYRotation); _target.useNormalSurface = EditorGUILayout.Toggle("Normal surface rotation for decal", _target.useNormalSurface); _target.decalLifeTime = EditorGUILayout.FloatField("Time until decal is destroyed", _target.decalLifeTime); _target.decalStartFadeTime = EditorGUILayout.FloatField("Decal fade time", _target.decalStartFadeTime); _target.minDecalSize = EditorGUILayout.FloatField("Minimum decal size", _target.minDecalSize); _target.maxDecalSize = EditorGUILayout.FloatField("Maximum decal size", _target.maxDecalSize); } } GUILayout.EndVertical(); //If we changed the GUI aply the new values to the script if (GUI.changed) { EditorUtility.SetDirty(_target); } }
public void AddDecal(DeferredDecal d) { RemoveDecal(d); m_Decals.Add(d); }