private void CallLightning() { // Important, make sure this script is assigned properly, or you will get null ref exceptions. DigitalRuby.ThunderAndLightning.LightningBoltScript script = gameObject.GetComponent <DigitalRuby.ThunderAndLightning.LightningBoltScript>(); int count = 5; float duration = 0.3939312f; float delay = 0.0f; int seed = -210785313; System.Random r = new System.Random(seed); Vector3 start = new Vector3(0f, 241.0437f, 500f); Vector3 end = new Vector3(0f, -239.0398f, 500f); int generations = 5; float chaosFactor = 0.3054504f; float trunkWidth = 10.39684f; float glowIntensity = 0.201021f; float glowWidthMultiplier = 4f; float forkedness = 0.5f; float singleDuration = Mathf.Max(1.0f / 30.0f, (duration / (float)count)); float fadePercent = 0.15f; float growthMultiplier = 0f; System.Collections.Generic.List <DigitalRuby.ThunderAndLightning.LightningBoltParameters> paramList = new System.Collections.Generic.List <DigitalRuby.ThunderAndLightning.LightningBoltParameters>(); while (count-- > 0) { DigitalRuby.ThunderAndLightning.LightningBoltParameters parameters = new DigitalRuby.ThunderAndLightning.LightningBoltParameters { Start = start, End = end, Generations = generations, LifeTime = (count == 1 ? singleDuration : (singleDuration * (((float)r.NextDouble() * 0.4f) + 0.8f))), Delay = delay, ChaosFactor = chaosFactor, TrunkWidth = trunkWidth, GlowIntensity = glowIntensity, GlowWidthMultiplier = glowWidthMultiplier, Forkedness = forkedness, Random = r, FadePercent = fadePercent, // set to 0 to disable fade in / out GrowthMultiplier = growthMultiplier }; paramList.Add(parameters); delay += (singleDuration * (((float)r.NextDouble() * 0.8f) + 0.4f)); } script.CreateLightningBolts(paramList); }
public void GenerateSpark() { // Important, make sure this script is assigned properly, or you will get null ref exceptions. DigitalRuby.ThunderAndLightning.LightningBoltScript script = gameObject.GetComponent <DigitalRuby.ThunderAndLightning.LightningBoltScript>(); int count = 1; float duration = 0.25f; float delay = 0.0f; System.Random r = new System.Random(); Vector3 start = this.sparkingStartPoint.transform.position; Vector3 end = this.sparkingEndPoint.transform.position; int generations = 6; float chaosFactor = 0.2f; float trunkWidth = 0.05f; float glowIntensity = 0.1793653f; float glowWidthMultiplier = 4f; float forkedness = 0.5f; float singleDuration = Mathf.Max(1.0f / 30.0f, (duration / (float)count)); float fadePercent = 0.15f; float growthMultiplier = 0f; while (count-- > 0) { DigitalRuby.ThunderAndLightning.LightningBoltParameters parameters = new DigitalRuby.ThunderAndLightning.LightningBoltParameters { Start = start, End = end, Generations = generations, LifeTime = (count == 1 ? singleDuration : (singleDuration * (((float)r.NextDouble() * 0.4f) + 0.8f))), Delay = delay, ChaosFactor = chaosFactor, TrunkWidth = trunkWidth, GlowIntensity = glowIntensity, GlowWidthMultiplier = glowWidthMultiplier, Forkedness = forkedness, Random = r, FadePercent = fadePercent, // set to 0 to disable fade in / out GrowthMultiplier = growthMultiplier }; script.CreateLightningBolt(parameters); delay += (singleDuration * (((float)r.NextDouble() * 0.8f) + 0.4f)); } }
private void OnEnable() { inspectorTarget = target as LightningBoltScript; //Get the layer names string[] layerNames = GetSortingLayerNames(); //Put them in a GUIContent variable, so that we can display a tooltip later sortingLayerNames = new GUIContent[layerNames.Length]; string currentSortLayerName = (inspectorTarget.SortLayerName ?? string.Empty); for (int i = 0; i < sortingLayerNames.Length; i++) { sortingLayerNames[i] = new GUIContent(layerNames[i] ?? string.Empty); if (currentSortLayerName == layerNames[i]) { chosenIndex = i; } } }
private void OnEnable() { inspectorTarget = target as LightningBoltScript; //Get the layer names string[] layerNames = GetSortingLayerNames(); //Put them in a GUIContent variable, so that we can display a tooltip later sortingLayerNames = new GUIContent[layerNames.Length]; string currentSortLayerName = (inspectorTarget.SortLayerName ?? string.Empty); for (int i = 0; i < sortingLayerNames.Length; i++) { sortingLayerNames[i] = new GUIContent(layerNames[i] ?? string.Empty); if (currentSortLayerName == layerNames[i]) { chosenIndex = i; } } }
public void Initialize(Camera camera, bool useWorldSpace, LightningBoltMeshRenderer lightningBoltRenderer, GameObject parent, LightningBoltScript script, ParticleSystem originParticleSystem, ParticleSystem destParticleSystem, ICollection<LightningBoltParameters> parameters) { #if DEBUG // setup properties if (parameters == null || lightningBoltRenderer == null || parameters.Count == 0 || script == null) { Debug.LogError("Parameters, renderer and script must be non-null"); return; } #endif this.Camera = camera; this.UseWorldSpace = useWorldSpace; this.SortLayerName = script.SortLayerName; this.SortOrderInLayer = script.SortOrderInLayer; this.lightningBoltRenderer = lightningBoltRenderer; this.Parent = parent; this.Script = script; CheckForGlow(parameters); lightningBoltRenderer.Begin(this); MinimumDelay = float.MaxValue; int maxLightsForEachParameters = MaximumLightsPerBatch / parameters.Count; foreach (LightningBoltParameters p in parameters) { ProcessParameters(p, originParticleSystem, destParticleSystem, maxLightsForEachParameters); } lightningBoltRenderer.End(this); }