@@ -45,17 +45,38 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\AnimatedLineRenderer\Demo\DemoScriptDraw.cs" />
<Compile Include="Assets\AnimatedLineRenderer\Demo\DemoScriptPhasor.cs" />
<Compile Include="Assets\AnimatedLineRenderer\Scripts\AnimatedLineRenderer.cs" />
<Compile Include="Assets\AnimatedLineRenderer\Scripts\PhasorScript.cs" />
<Compile Include="Assets\FastLineRenderer\Demo\FastLineRendererDemoScript.cs" />
<Compile Include="Assets\FastLineRenderer\Script\FastLineRenderer.cs" />
<Compile Include="Assets\FastLineRenderer\Script\FastLineRendererEditorUtilities.cs" />
<Compile Include="Assets\FastLineRenderer\Script\PathGenerator.cs" />
<Compile Include="Assets\Reporter\MultiKeyDictionary.cs" />
<Compile Include="Assets\Reporter\Reporter.cs" />
<Compile Include="Assets\Reporter\ReporterGUI.cs" />
<Compile Include="Assets\Reporter\ReporterMessageReceiver.cs" />
<Compile Include="Assets\Reporter\Test\Rotate.cs" />
<Compile Include="Assets\Reporter\Test\TestReporter.cs" />
<Compile Include="Assets\VolumetricLines\ExampleScenes\ExampleScripts\CannonBehavior.cs" />
<Compile Include="Assets\VolumetricLines\ExampleScenes\ExampleScripts\CreateSinShapedLineStrip.cs" />
<Compile Include="Assets\VolumetricLines\ExampleScenes\ExampleScripts\ShotBehavior.cs" />
<Compile Include="Assets\VolumetricLines\Scripts\SetFovGlobalShaderVariable.cs" />
<Compile Include="Assets\VolumetricLines\Scripts\Utils\ExposePropertyAttribute.cs" />
<Compile Include="Assets\VolumetricLines\Scripts\Utils\TransformExtensionMethods.cs" />
<Compile Include="Assets\VolumetricLines\Scripts\VolumetricLineBehavior.cs" />
<Compile Include="Assets\VolumetricLines\Scripts\VolumetricLineStripBehavior.cs" />
<Compile Include="Assets\VolumetricLines\Scripts\VolumetricMultiLineBehavior.cs" />
<Compile Include="Assets\_Scripts\BugMovement.cs" />
<Compile Include="Assets\_Scripts\CloudMovement.cs" />
<Compile Include="Assets\_Scripts\Earthquake.cs" />
<Compile Include="Assets\_Scripts\Floater.cs" />
<Compile Include="Assets\_Scripts\FrogController.cs" />
<Compile Include="Assets\_Scripts\LilyPadController.cs" />
<Compile Include="Assets\_Scripts\LineRendererer.cs" />
<Compile Include="Assets\_Scripts\SetPivot.cs" />
<Compile Include="Assets\_Scripts\Tongue.cs" />
<Compile Include="Assets\_Scripts\WaveMotion.cs" />
<None Include="Assets\Standard Assets\Effects\GlassRefraction\Shaders\GlassStainedBumpDistort.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlendOneOne.shader" />
@@ -66,9 +87,11 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\SunShaftsComposite.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\ColorCorrectionCurves.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\ScreenSpaceAmbientObscurance.shader" />
<None Include="Assets\FastLineRenderer\Material\FastLineRendererShaderNoGlow.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\NFAA.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\ScreenSpaceRaytrace.cginc" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\TiltShiftHdrLensBlur.shader" />
<None Include="Assets\VolumetricLines\Shaders\VolumetricLineShaderAlphaBlended.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\VignetteShader.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfFieldScatter.shader" />
<None Include="Assets\Standard Assets\Effects\TessellationShaders\Shaders\BumpedSpecularSmooth.shader" />
@@ -79,8 +102,10 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\SSAA.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\RadialBlur.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfFieldDX11.shader" />
<None Include="Assets\AnimatedLineRenderer\Readme.txt" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\ContrastComposite.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAAPreset3.shader" />
<None Include="Assets\VolumetricLines\Shaders\VolumetricLineShaderAdditive.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\FisheyeShader.shader" />
<None Include="Assets\Standard Assets\Vehicles\Car\Shaders\DiffuseReflectiveShader.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\Contrast Stretch\Apply.shader" />
@@ -108,6 +133,7 @@
<None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonLitOutline.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\Contrast Stretch\Luminance.shader" />
<None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonLit.shader" />
<None Include="Assets\VolumetricLines\Shaders\VolumetricLineShaderAdditiveFast.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\ColorCorrectionSelective.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\Bokeh34.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\CameraMotionBlurDX11.shader" />
@@ -130,15 +156,19 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\Contrast Stretch\Adaptation.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\NoiseAndGrain.shader" />
<None Include="Assets\Standard Assets\Vehicles\Car\CarGuidelines.txt" />
<None Include="Assets\VolumetricLines\Shaders\VolumetricLineStripShaderAdditive.shader" />
<None Include="Assets\Standard Assets\Effects\Projectors\Shaders\ProjectorMultiply.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\VignettingShader.shader" />
<None Include="Assets\Standard Assets\Characters\ThirdPersonCharacter\ThirdPersonCharacterGuidelines.txt" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\Tonemapper.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BrightPassFilter.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAA2.shader" />
<None Include="Assets\VolumetricLines\Shaders\VolumetricLineStripShaderAlphaBlended.shader" />
<None Include="Assets\FastLineRenderer\Readme.txt" />
<None Include="Assets\Standard Assets\Cameras\CameraGuidelines.txt" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\ColorCorrection3DLut.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\LensFlareCreate.shader" />
<None Include="Assets\VolumetricLines\Shaders\VolumetricLineShaderAlphaBlendedFast.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\EdgeDetectNormals.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\PrepareSunShaftsBlur.shader" />
<None Include="Assets\Standard Assets\Characters\FirstPersonCharacter\FirstPersonCharacterGuidelines.txt" />
@@ -150,6 +180,7 @@
<None Include="Assets\Standard Assets\Characters\RollerBall\RollerBallGuidelines.txt" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\SimpleClear.shader" />
<None Include="Assets\Standard Assets\ParticleSystems\Shaders\PriorityParticleAdd.shader" />
<None Include="Assets\FastLineRenderer\Material\FastLineRendererShader.shader" />
<None Include="Assets\Standard Assets\Effects\TessellationShaders\Shaders\BumpedSpecularDisplacement.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAA3Console.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAAPreset2.shader" />
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,35 @@
using UnityEngine;
using System.Collections;

namespace DigitalRuby.AnimatedLineRenderer
{
public class DemoScriptDraw : MonoBehaviour
{
public AnimatedLineRenderer AnimatedLine;

private void Start()
{

}

private void Update()
{
if (AnimatedLine == null)
{
return;
}
else if (Input.GetMouseButton(0))
{
Vector3 pos = Input.mousePosition;

pos = Camera.main.ScreenToWorldPoint(new Vector3(pos.x, pos.y, AnimatedLine.transform.position.z));

AnimatedLine.Enqueue(pos);
}
else if (Input.GetKey(KeyCode.R))
{
AnimatedLine.ResetAfterSeconds(0.5f, null);
}
}
}
}
@@ -0,0 +1,92 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

namespace DigitalRuby.AnimatedLineRenderer
{
public class DemoScriptPhasor : MonoBehaviour
{
public PhasorScript PhasorScript;
public GameObject AsteroidPrefab;
public AudioSource ExplosionSound;
public ParticleSystem ExplosionParticleSystem;

private readonly List<GameObject> asteroids = new List<GameObject>();

private int score;

private void CreateAsteroid()
{
GameObject clone = Instantiate(AsteroidPrefab);
float scale = UnityEngine.Random.Range(0.5f, 2.0f);
float rotation = UnityEngine.Random.Range(0.0f, 360.0f);
clone.transform.localScale = new Vector3(scale, scale, 1.0f);
clone.transform.rotation = Quaternion.Euler(0.0f, 0.0f, rotation);
float x = UnityEngine.Random.Range(0.5f, 0.9f);
float y = UnityEngine.Random.Range(0.1f, 0.9f);
Vector3 worldPos = Camera.main.ViewportToWorldPoint(new Vector3(x, y, 0.0f));
worldPos.z = 0.0f;
clone.transform.position = worldPos;

float maxVelocity = 8.0f;
clone.GetComponent<Rigidbody2D>().velocity = new Vector2(UnityEngine.Random.Range(0.0f, maxVelocity), UnityEngine.Random.Range(0.0f, maxVelocity));
clone.GetComponent<Rigidbody2D>().angularVelocity = UnityEngine.Random.Range(0.0f, 4.0f);

asteroids.Add(clone);
}

private void DestroyAsteroid(GameObject asteroid)
{
if (asteroid != null)
{
ExplosionSound.PlayOneShot(ExplosionSound.clip);
ExplosionParticleSystem.transform.position = asteroid.transform.position;
short pieces = (short)Mathf.Max(8, (50.0f * asteroid.transform.localScale.x * asteroid.transform.localScale.x));
ExplosionParticleSystem.emission.SetBursts(new ParticleSystem.Burst[] { new ParticleSystem.Burst(0.0f, pieces) }, 1);
ExplosionParticleSystem.Play();
GameObject.Destroy(asteroid);
}
}

private void OnHit(RaycastHit2D[] hits)
{
foreach (RaycastHit2D hit in hits)
{
DestroyAsteroid(hit.collider.gameObject);
score++;
}
GameObject label = GameObject.Find("ScoreLabel");
label.GetComponent<UnityEngine.UI.Text>().text = "Score: " + score;
}

private void Start()
{
PhasorScript.HitCallback = OnHit;
}

private void Update()
{
if (Input.GetMouseButtonDown(0))
{
Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
pos.z = 0.0f;
PhasorScript.Fire(pos);
}

for (int i = asteroids.Count - 1; i >= 0; i--)
{
GameObject obj = asteroids[i];
if (obj == null || !obj.GetComponent<Renderer>().isVisible)
{
GameObject.Destroy(obj);
asteroids.RemoveAt(i);
}
}

if (UnityEngine.Random.Range(0, 50) == 5)
{
CreateAsteroid();
}
}
}
}
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,15 @@
Animated Line Renderer for Unity
(c) 2016 Digital Ruby, LLC
Created by Jeff Johnson

Animated Line Renderer is a very simple yet powerful way to animate the Unity Line Renderer. Easily add points to a line and specify how long it should take to get to the next point.

Two demo scenes are provided. One is a draw canvas, where you can drag the mouse and the animated line will follow the mouse cursor. The other is a simple asteroids demo with a phasor that shoots out and blows up asteroids.

The API is quite simple, and the best way to see it in action is to look at DemoScriptDraw.cs and DemoScriptPhasor.cs. I've also provided some prefabs for you to get started with.

Please let me know of any feedback at jjxtra@gmail.com.

Thank you!

- Jeff
@@ -0,0 +1,272 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;

namespace DigitalRuby.AnimatedLineRenderer
{
[RequireComponent(typeof(LineRenderer))]
public class AnimatedLineRenderer : MonoBehaviour
{
[Tooltip("The minimum distance that must be in between line segments (0 for infinite). Attempts to make lines with distances smaller than this will fail.")]
public float MinimumDistance = 0.0f;

[Tooltip("Seconds that each new line segment should animate with")]
public float SecondsPerLine = 0.1f;

[Tooltip("Start color for the line renderer since Unity does not provider a getter for this")]
public Color StartColor = Color.white;

[Tooltip("End color for the line renderer since Unity does not provide a getter for this")]
public Color EndColor = Color.white;

[Tooltip("Start line width")]
public float StartWidth = 2.0f;

[Tooltip("End line width")]
public float EndWidth = 2.0f;

[Tooltip("Sort layer name")]
public string SortLayerName = "Default";

[Tooltip("Order in sort layer")]
public int OrderInSortLayer = 1;

private struct QueueItem
{
public Vector3 Position;
public float ElapsedSeconds;
public float TotalSeconds;
public float TotalSecondsInverse;
}

private LineRenderer lineRenderer;
private readonly Queue<QueueItem> queue = new Queue<QueueItem>();
private QueueItem prev;
private QueueItem current;
private QueueItem? lastQueued;
private int index = -1;
private float remainder;

private void ProcessCurrent()
{
if (current.ElapsedSeconds == current.TotalSeconds)
{
if (queue.Count == 0)
{
return;
}
else
{
prev = current;
current = queue.Dequeue();
if (++index == 0)
{
lineRenderer.SetVertexCount(1);
StartPoint = current.Position;
current.ElapsedSeconds = current.TotalSeconds = current.TotalSecondsInverse = 0.0f;
lineRenderer.SetPosition(0, current.Position);
return;
}
else
{
lineRenderer.SetVertexCount(index + 1);
}
}
}

float newElapsedSeconds = current.ElapsedSeconds + Time.deltaTime + remainder;
if (newElapsedSeconds > current.TotalSeconds)
{
remainder = newElapsedSeconds - current.TotalSeconds;
current.ElapsedSeconds = current.TotalSeconds;
}
else
{
remainder = 0.0f;
current.ElapsedSeconds = newElapsedSeconds;
}
current.ElapsedSeconds = Mathf.Min(current.TotalSeconds, current.ElapsedSeconds + Time.deltaTime);
float lerp = current.TotalSecondsInverse * current.ElapsedSeconds;
EndPoint = Vector3.Lerp(prev.Position, current.Position, lerp);
lineRenderer.SetPosition(index, EndPoint);
}

private void Start()
{
lineRenderer = GetComponent<LineRenderer>();
lineRenderer.SetVertexCount(0);
}

private void Update()
{
ProcessCurrent();
if (!Resetting)
{
lineRenderer.SetColors(StartColor, EndColor);
lineRenderer.SetWidth(StartWidth, EndWidth);
lineRenderer.sortingLayerName = SortLayerName;
lineRenderer.sortingOrder = OrderInSortLayer;
}
}

private IEnumerator ResetAfterSecondsInternal(float seconds, Action callback)
{
if (seconds <= 0.0f)
{
Reset();
if (callback != null)
{
callback();
}
yield break;
}

float elapsedSeconds = 0.0f;
float secondsInverse = 1.0f / seconds;
Color c1 = new Color(StartColor.r, StartColor.g, StartColor.b, 1.0f);
Color c2 = new Color(EndColor.r, EndColor.g, EndColor.b, 1.0f);

while (elapsedSeconds < seconds)
{
float a = 1.0f - (secondsInverse * elapsedSeconds);
elapsedSeconds += Time.deltaTime;
c1.a = a;
c2.a = a;
lineRenderer.SetColors(c1, c2);
yield return new WaitForSeconds(0.01f);
}
Reset();
if (callback != null)
{
callback();
}
}

/// <summary>
/// Enqueue a line segment, using SecondsPerLine for the duration
/// </summary>
/// <param name="pos">Position of the line segment</param>
/// <returns>True if enqueued, false if not</returns>
public bool Enqueue(Vector3 pos)
{
return Enqueue(pos, SecondsPerLine);
}

/// <summary>
/// Enqueue a line segment
/// </summary>
/// <param name="pos">Position of the line segment</param>
/// <param name="duration">Duration the line segment should take to become the full length</param>
/// <returns>True if enqueued, false if not</returns>
public bool Enqueue(Vector3 pos, float duration)
{
if (Resetting)
{
return false;
}
else if (MinimumDistance > 0.0f && lastQueued != null)
{
Vector3 prevPos = lastQueued.Value.Position;
float distance = Vector3.Distance(prevPos, pos);
if (distance < MinimumDistance)
{
return false;
}
else
{
// Debug.LogFormat("Distance between {0} and {1}: {2}", prevPos, pos, distance);
}
}

float durationSeconds = Mathf.Max(0.0f, duration);
QueueItem item = new QueueItem
{
Position = pos,
TotalSecondsInverse = (durationSeconds == 0.0f ? 0.0f : 1.0f / durationSeconds),
TotalSeconds = durationSeconds,
ElapsedSeconds = 0.0f
};
queue.Enqueue(item);
lastQueued = item;

return true;
}

/// <summary>
/// Reset the line renderer, setting everything back to defaults
/// </summary>
public void Reset()
{
index = -1;
prev = current = new QueueItem();
lastQueued = null;
if (lineRenderer != null)
{
lineRenderer.SetVertexCount(0);
}
remainder = 0.0f;
queue.Clear();
Resetting = false;
StartPoint = EndPoint = Vector3.zero;
}

/// <summary>
/// Reset the line renderer, fading out smoothly over seconds
/// </summary>
/// <param name="seconds">Seconds to fade out</param>
public void ResetAfterSeconds(float seconds)
{
ResetAfterSeconds(seconds, null, null);
}

/// <summary>
/// Reset the line renderer, fading out smoothly over seconds
/// </summary>
/// <param name="seconds">Seconds to fade out</param>
/// <param name="endPoint">Force the end point to a new value (optional)</param>
public void ResetAfterSeconds(float seconds, Vector3? endPoint)
{
ResetAfterSeconds(seconds, endPoint, null);
}

/// <summary>
/// Reset the line renderer, fading out smoothly over seconds
/// </summary>
/// <param name="seconds">Seconds to fade out</param>
/// <param name="callback">Callback when the fade out is finished</param>
public void ResetAfterSeconds(float seconds, Vector3? endPoint, Action callback)
{
Resetting = true;
if (endPoint != null)
{
current.Position = endPoint.Value;
if (index > 0)
{
lineRenderer.SetPosition(index, endPoint.Value);
}
}
StartCoroutine(ResetAfterSecondsInternal(seconds, callback));
}

/// <summary>
/// The Unity Line Renderer
/// </summary>
public LineRenderer LineRenderer { get { return lineRenderer; } }

/// <summary>
/// The current line start point (point index 0)
/// </summary>
public Vector3 StartPoint { get; private set; }

/// <summary>
/// The current line end point (point index n - 1)
/// </summary>
public Vector3 EndPoint { get; private set; }

/// <summary>
/// Is the line renderer in the process of resetting?
/// </summary>
public bool Resetting { get; private set; }
}
}
@@ -0,0 +1,124 @@
using UnityEngine;

using System;
using System.Collections;

namespace DigitalRuby.AnimatedLineRenderer
{
[RequireComponent(typeof(AnimatedLineRenderer))]
public class PhasorScript : MonoBehaviour
{
/// <summary>
/// Action that will be called whenever objects are hit by the phasor
/// </summary>
[HideInInspector]
public Action<RaycastHit2D[]> HitCallback;

[Tooltip("Source of the phasor")]
public GameObject Source;

[Tooltip("Target to fire at")]
public GameObject Target;

[Tooltip("Sound to make when the phasor fires")]
public AudioSource FireSound;

private AnimatedLineRenderer lineRenderer;
private bool firing;
private bool endingFiring;
private int endFireToken;

private void Start()
{
lineRenderer = GetComponent<AnimatedLineRenderer>();
}

private void Update()
{
if (CanEndFire())
{
RaycastHit2D[] hits = Physics2D.CircleCastAll(lineRenderer.StartPoint, lineRenderer.EndWidth * 0.5f,
lineRenderer.EndPoint - lineRenderer.StartPoint, Vector3.Distance(lineRenderer.EndPoint, lineRenderer.StartPoint));
if (hits != null && hits.Length != 0)
{
EndFire(hits[0].point);
if (HitCallback != null)
{
HitCallback(hits);
}
}
}
}

private bool CanEndFire()
{
return (firing && !endingFiring && !lineRenderer.Resetting);
}

private void EndFire(Vector3? endPoint)
{
endFireToken++;
endingFiring = true;
lineRenderer.ResetAfterSeconds(0.2f, endPoint, () =>
{
firing = false;
endingFiring = false;
});
}

private IEnumerator EndFireDelay(float delay, int token)
{
if (delay > 0.0f)
{
yield return new WaitForSeconds(delay);
}

if (endFireToken == token)
{
EndFire(null);
}
}

/// <summary>
/// Fire the phasor, using the source and target parameters of this class
/// </summary>
/// <returns>True if able to fire, false if already firing</returns>
public bool Fire()
{
return Fire(Source.transform.position, Target.transform.position);
}

/// <summary>
/// Fire the phasor, using the target specified
/// </summary>
/// <param name="target">Target to fire at</param>
/// <returns>True if able to fire, false if already firing</returns>
public bool Fire(Vector3 target)
{
return Fire(Source.transform.position, target);
}

/// <summary>
/// Fire the phasor at a target
/// </summary>
/// <param name="target">Target to fire at</param>
/// <returns>True if able to fire, false if already firing</returns>
public bool Fire(Vector3 source, Vector3 target)
{
if (firing)
{
return false;
}

firing = true;
lineRenderer.Enqueue(source);
lineRenderer.Enqueue(target);
StartCoroutine(EndFireDelay(lineRenderer.SecondsPerLine, ++endFireToken));
if (FireSound != null)
{
FireSound.Play();
}
return true;
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,217 @@
<?xml version="1.0" encoding="UTF-8"?>
<data version="1.0">
<struct type="Settings">
<key>fileFormatVersion</key>
<int>3</int>
<key>texturePackerVersion</key>
<string>4.0.2</string>
<key>fileName</key>
<string>/Users/Josh/Code/Unity/Tactus Animus/Assets/Custom_Assets/cust.tps</string>
<key>autoSDSettings</key>
<array>
<struct type="AutoSDSettings">
<key>scale</key>
<double>1</double>
<key>extension</key>
<string></string>
<key>spriteFilter</key>
<string></string>
<key>acceptFractionalValues</key>
<false/>
<key>maxTextureSize</key>
<QSize>
<key>width</key>
<int>-1</int>
<key>height</key>
<int>-1</int>
</QSize>
</struct>
</array>
<key>allowRotation</key>
<true/>
<key>premultiplyAlpha</key>
<false/>
<key>shapeDebug</key>
<false/>
<key>dpi</key>
<uint>72</uint>
<key>dataFormat</key>
<string>spritesheet-only</string>
<key>textureFileName</key>
<filename>../../../../Frogs.2.png</filename>
<key>flipPVR</key>
<false/>
<key>pvrCompressionQuality</key>
<enum type="SettingsBase::PvrCompressionQuality">PVR_QUALITY_NORMAL</enum>
<key>atfCompressData</key>
<false/>
<key>mipMapMinSize</key>
<uint>32768</uint>
<key>etc1CompressionQuality</key>
<enum type="SettingsBase::Etc1CompressionQuality">ETC1_QUALITY_LOW_PERCEPTUAL</enum>
<key>dxtCompressionMode</key>
<enum type="SettingsBase::DxtCompressionMode">DXT_PERCEPTUAL</enum>
<key>jxrColorFormat</key>
<enum type="SettingsBase::JpegXrColorMode">JXR_YUV444</enum>
<key>jxrTrimFlexBits</key>
<uint>0</uint>
<key>jxrCompressionLevel</key>
<uint>0</uint>
<key>ditherType</key>
<enum type="SettingsBase::DitherType">NearestNeighbour</enum>
<key>backgroundColor</key>
<uint>0</uint>
<key>libGdx</key>
<struct type="LibGDX">
<key>filtering</key>
<struct type="LibGDXFiltering">
<key>x</key>
<enum type="LibGDXFiltering::Filtering">Linear</enum>
<key>y</key>
<enum type="LibGDXFiltering::Filtering">Linear</enum>
</struct>
</struct>
<key>shapePadding</key>
<uint>0</uint>
<key>jpgQuality</key>
<uint>80</uint>
<key>pngOptimizationLevel</key>
<uint>0</uint>
<key>webpQualityLevel</key>
<uint>101</uint>
<key>textureSubPath</key>
<string></string>
<key>textureFormat</key>
<enum type="SettingsBase::TextureFormat">png</enum>
<key>borderPadding</key>
<uint>0</uint>
<key>maxTextureSize</key>
<QSize>
<key>width</key>
<int>2048</int>
<key>height</key>
<int>2048</int>
</QSize>
<key>fixedTextureSize</key>
<QSize>
<key>width</key>
<int>-1</int>
<key>height</key>
<int>-1</int>
</QSize>
<key>reduceBorderArtifacts</key>
<false/>
<key>algorithmSettings</key>
<struct type="AlgorithmSettings">
<key>algorithm</key>
<enum type="AlgorithmSettings::AlgorithmId">Basic</enum>
<key>freeSizeMode</key>
<enum type="AlgorithmSettings::AlgorithmFreeSizeMode">Best</enum>
<key>sizeConstraints</key>
<enum type="AlgorithmSettings::SizeConstraints">AnySize</enum>
<key>forceSquared</key>
<false/>
<key>forceWordAligned</key>
<false/>
<key>maxRects</key>
<struct type="AlgorithmMaxRectsSettings">
<key>heuristic</key>
<enum type="AlgorithmMaxRectsSettings::Heuristic">Best</enum>
</struct>
<key>basic</key>
<struct type="AlgorithmBasicSettings">
<key>sortBy</key>
<enum type="AlgorithmBasicSettings::SortBy">Name</enum>
<key>order</key>
<enum type="AlgorithmBasicSettings::Order">Descending</enum>
</struct>
</struct>
<key>andEngine</key>
<struct type="AndEngine">
<key>minFilter</key>
<enum type="AndEngine::MinFilter">Linear</enum>
<key>packageName</key>
<string>Texture</string>
<key>wrap</key>
<struct type="AndEngineWrap">
<key>s</key>
<enum type="AndEngineWrap::Wrap">Clamp</enum>
<key>t</key>
<enum type="AndEngineWrap::Wrap">Clamp</enum>
</struct>
<key>magFilter</key>
<enum type="AndEngine::MagFilter">MagLinear</enum>
</struct>
<key>dataFileNames</key>
<map type="GFileNameMap"/>
<key>multiPack</key>
<false/>
<key>forceIdenticalLayout</key>
<false/>
<key>outputFormat</key>
<enum type="SettingsBase::OutputFormat">RGBA8888</enum>
<key>contentProtection</key>
<struct type="ContentProtection">
<key>key</key>
<string></string>
</struct>
<key>autoAliasEnabled</key>
<false/>
<key>trimSpriteNames</key>
<false/>
<key>prependSmartFolderName</key>
<false/>
<key>cleanTransparentPixels</key>
<false/>
<key>globalSpriteSettings</key>
<struct type="SpriteSettings">
<key>scale</key>
<double>1</double>
<key>scaleMode</key>
<enum type="ScaleMode">Smooth</enum>
<key>extrude</key>
<uint>0</uint>
<key>trimThreshold</key>
<uint>1</uint>
<key>trimMargin</key>
<uint>1</uint>
<key>trimMode</key>
<enum type="SpriteSettings::TrimMode">None</enum>
<key>tracerTolerance</key>
<int>200</int>
<key>heuristicMask</key>
<false/>
<key>pivotPoint</key>
<enum type="SpriteSettings::PivotPoint">Center</enum>
</struct>
<key>fileList</key>
<array>
<filename>../../../../../Downloads/ITP - Emotion Game/frog_blinking_concentrated.png</filename>
<filename>../../../../../Downloads/ITP - Emotion Game/frog_blinking_default.png</filename>
<filename>../../../../../Downloads/ITP - Emotion Game/frog_blinking_upset.png</filename>
<filename>../../../../../Downloads/ITP - Emotion Game/frog_concentrated.png</filename>
<filename>../../../../../Downloads/ITP - Emotion Game/frog_default.png</filename>
<filename>../../../../../Downloads/ITP - Emotion Game/frog_upset.png</filename>
</array>
<key>ignoreFileList</key>
<array/>
<key>replaceList</key>
<array/>
<key>ignoredWarnings</key>
<array/>
<key>commonDivisorX</key>
<uint>1</uint>
<key>commonDivisorY</key>
<uint>1</uint>
<key>packNormalMaps</key>
<false/>
<key>autodetectNormalMaps</key>
<true/>
<key>normalMapFilter</key>
<string></string>
<key>normalMapSuffix</key>
<string></string>
<key>normalMapSheetFileName</key>
<filename></filename>
</struct>
</data>
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,352 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using System;

namespace DigitalRuby.FastLineRenderer
{
[ExecuteInEditMode]
public class FastLineRendererDemoScript : MonoBehaviour
{
public FastLineRenderer LineRenderer;
public LineRenderer UnityLineRenderer;
public Toggle UseUnityLineRendererToggle;
public Text LineCountLabel;
public float MoveSpeed = 50.0f;
public bool EnableMouseLook;
public bool ShowCurves;
public bool ShowEffects;

private List<Vector3> UnityLineRendererPositions = new List<Vector3>();
private float deltaTime = 0.0f;
private float msec = 0.0f;
private float fps = 0.0f;
private int lineCount;

private enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
private RotationAxes axes = RotationAxes.MouseXAndY;
private float sensitivityX = 15F;
private float sensitivityY = 15F;
private float minimumX = -360F;
private float maximumX = 360F;
private float minimumY = -60F;
private float maximumY = 60F;
private float rotationX = 0F;
private float rotationY = 0F;
private Quaternion originalRotation;

private void UpdateMovement()
{
if (Camera.main.orthographic)
{
return;
}

float speed = MoveSpeed * Time.deltaTime;

if (Input.GetKey(KeyCode.W))
{
Camera.main.transform.Translate(0.0f, 0.0f, speed);
}
if (Input.GetKey(KeyCode.S))
{
Camera.main.transform.Translate(0.0f, 0.0f, -speed);
}
if (Input.GetKey(KeyCode.A))
{
Camera.main.transform.Translate(-speed, 0.0f, 0.0f);
}
if (Input.GetKey(KeyCode.D))
{
Camera.main.transform.Translate(speed, 0.0f, 0.0f);
}
}

private void UpdateMouseLook()
{
if (Camera.main.orthographic || !EnableMouseLook)
{
return;
}
else if (axes == RotationAxes.MouseXAndY)
{
// Read the mouse input axis
rotationX += Input.GetAxis("Mouse X") * sensitivityX;
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;

rotationX = ClampAngle(rotationX, minimumX, maximumX);
rotationY = ClampAngle(rotationY, minimumY, maximumY);

Quaternion xQuaternion = Quaternion.AngleAxis(rotationX, Vector3.up);
Quaternion yQuaternion = Quaternion.AngleAxis(rotationY, -Vector3.right);

transform.localRotation = originalRotation * xQuaternion * yQuaternion;
}
else if (axes == RotationAxes.MouseX)
{
rotationX += Input.GetAxis("Mouse X") * sensitivityX;
rotationX = ClampAngle(rotationX, minimumX, maximumX);

Quaternion xQuaternion = Quaternion.AngleAxis(rotationX, Vector3.up);
transform.localRotation = originalRotation * xQuaternion;
}
else
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = ClampAngle(rotationY, minimumY, maximumY);

Quaternion yQuaternion = Quaternion.AngleAxis(-rotationY, Vector3.right);
transform.localRotation = originalRotation * yQuaternion;
}
}

private void OnGUI()
{
if (deltaTime == 0.0f)
{
return;
}

int w = Screen.width, h = Screen.height;

GUIStyle style = new GUIStyle();

Rect rect = new Rect(12, h - 42, w, h * 2 / 100);
style.alignment = TextAnchor.UpperLeft;
style.fontSize = 30;
style.normal.textColor = new Color(1.0f, 1.0f, 1.0f, 1.0f);

msec = deltaTime * 1000.0f;
fps = 1.0f / deltaTime;

string text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps);
GUI.Label(rect, text, style);
}

private byte RandomByte()
{
return (byte)UnityEngine.Random.Range(0, byte.MaxValue);
}

private Vector3 RandomVelocity(float c)
{
return new Vector3(UnityEngine.Random.Range(-c, c), UnityEngine.Random.Range(-c, c), UnityEngine.Random.Range(-c, c));
}

private void DoShowEffects()
{
FastLineRendererProperties props = new FastLineRendererProperties();
FastLineRenderer r = FastLineRenderer.CreateWithParent(null, LineRenderer);
r.Material.EnableKeyword("DISABLE_CAPS");
r.SetCapacity(8192 * FastLineRenderer.VerticesPerLine);
r.Turbulence = 350.0f;
r.BoundsScale = new Vector3(4.0f, 4.0f, 4.0f);
//r.JitterMultiplier = UnityEngine.Random.Range(0.25f, 1.5f);

const float maxLifeTimeSeconds = 1.5f;

for (int i = 0; i < 32; i++)
{
Vector3 pos = new Vector3(10.0f, Screen.height * 0.5f);
Vector3 pos2 = new Vector3(10.0f + (UnityEngine.Random.Range(50.0f, 150.0f)), Screen.height * 0.5f + (UnityEngine.Random.Range(-15.0f, 15.0f)));
props.Start = pos;
props.End = pos2;
props.Radius = UnityEngine.Random.Range(8.0f, 16.0f);
float s = UnityEngine.Random.Range(1.0f, maxLifeTimeSeconds);
props.SetLifeTime(s, s * UnityEngine.Random.Range(0.1f, 0.2f));
props.Color = new Color32(RandomByte(), RandomByte(), RandomByte(), RandomByte());
props.Velocity = RandomVelocity(20.0f);
props.Velocity.z = 0.0f;
props.AngularVelocity = UnityEngine.Random.Range(-0.1f, 0.1f);
r.AddLine(props);
}
r.Apply();

// send the script back into the cache, freeing up resources after max lifetime seconds.
r.SendToCacheAfter(TimeSpan.FromSeconds(maxLifeTimeSeconds));
}

private void UpdateDynamicLines()
{
if (!Input.GetKeyDown(KeyCode.Space) || LineRenderer == null)
{
return;
}
else if (ShowEffects)
{
DoShowEffects();
return;
}

const float maxLifeTimeSeconds = 5.0f;
FastLineRendererProperties props = new FastLineRendererProperties();
FastLineRenderer r = FastLineRenderer.CreateWithParent(null, LineRenderer);
r.Material.EnableKeyword("DISABLE_CAPS");
r.SetCapacity(8192 * FastLineRenderer.VerticesPerLine);
r.Turbulence = 150.0f;
r.BoundsScale = new Vector3(4.0f, 4.0f, 4.0f);
props.GlowIntensityMultiplier = 0.1f;
props.GlowWidthMultiplier = 4.0f;

for (int i = 0; i < 8192; i++)
{
Vector3 pos;
if (Camera.main.orthographic)
{
pos = UnityEngine.Random.insideUnitCircle;
pos.x *= Screen.width * UnityEngine.Random.Range(0.1f, 0.4f);
pos.y *= Screen.height * UnityEngine.Random.Range(0.1f, 0.4f);
}
else
{
pos = UnityEngine.Random.insideUnitSphere;
pos.x *= Screen.width * UnityEngine.Random.Range(0.5f, 2.0f);
pos.y *= Screen.height * UnityEngine.Random.Range(0.5f, 2.0f);
pos.z *= UnityEngine.Random.Range(-200.0f, 200.0f);
}
props.End = pos;
props.Radius = UnityEngine.Random.Range(1.0f, 4.0f);
float s = UnityEngine.Random.Range(1.0f, maxLifeTimeSeconds);
props.SetLifeTime(s, s * 0.15f);
props.Color = new Color32(RandomByte(), RandomByte(), RandomByte(), RandomByte());
props.Velocity = RandomVelocity(100.0f);
props.AngularVelocity = UnityEngine.Random.Range(-6.0f, 6.0f);
r.AddLine(props);
}
r.Apply();
r.SendToCacheAfter(TimeSpan.FromSeconds(maxLifeTimeSeconds));
}

private void CheckInput()
{
UpdateMovement();
UpdateMouseLook();
UpdateDynamicLines();
}

private void Start()
{
originalRotation = transform.localRotation;

if (UnityLineRenderer != null)
{
UnityLineRenderer.SetColors(Color.green, Color.blue);
}

AddCurvesAndSpline();
}

private void Update()
{
deltaTime += (Time.deltaTime - deltaTime) * 0.1f;

if (Camera.main.orthographic)
{
// 1 pixel = 1 world unit
Camera.main.orthographicSize = Screen.height * 0.5f;
Camera.main.transform.position = new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, -10.0f);
}

CheckInput();
}

private void AddCurvesAndSpline()
{
if (ShowCurves && Application.isPlaying && LineRenderer != null)
{
ShowCurves = false;
FastLineRendererProperties props = new FastLineRendererProperties();
props.GlowIntensityMultiplier = 0.5f;
props.Radius = 4.0f;
props.Color = UnityEngine.Color.cyan;
props.Start = new Vector3(Screen.width * 0.1f, Screen.height * 0.1f, 0.0f);
props.End = new Vector3(Screen.width * 1.1f, Screen.height * 1.0f, 0.0f);
LineRenderer.AppendCurve(props,
new Vector3(Screen.width * 0.33f, Screen.height * 0.67f, 0.0f), // control point 1
new Vector3(Screen.width * 0.67f, Screen.height * 0.33f, 0.0f), // control point 2
16, true, true);

props.Color = UnityEngine.Color.red;
props.Start = new Vector3(0.0f, Screen.height * 0.2f, 0.0f);
props.End = new Vector3(Screen.width * 1.2f, Screen.height * 0.2f, 0.0f);

Vector3[] spline = new Vector3[]
{
props.Start,
new Vector3(Screen.width * 0.2f, Screen.height * 0.8f, 0.0f),
new Vector3(Screen.width * 0.4f, Screen.height * 0.2f, 0.0f),
new Vector3(Screen.width * 0.6f, Screen.height * 0.8f, 0.0f),
new Vector3(Screen.width * 0.8f, Screen.height * 0.2f, 0.0f),
new Vector3(Screen.width, Screen.height * 0.8f, 0.0f),
props.End
};
LineRenderer.AppendSpline(props, spline, 128, FastLineRendererSplineFlags.StartCap | FastLineRendererSplineFlags.EndCap);

LineRenderer.Apply();
}
}

public void GenerateLotsOfLines()
{
for (int i = 0; i < 10; i++)
{
if (UseUnityLineRendererToggle != null && UseUnityLineRendererToggle.isOn && UnityLineRenderer != null)
{
for (int j = 0; j < FastLineRenderer.MaxLinesPerMesh; j++)
{
Vector3 pos = new Vector3(UnityEngine.Random.Range(0.0f, Screen.width), UnityEngine.Random.Range(0.0f, Screen.height), UnityEngine.Random.Range(-400.0f, 400.0f));
UnityLineRendererPositions.Add(pos);
}
UnityLineRenderer.SetVertexCount(UnityLineRendererPositions.Count);
UnityLineRenderer.SetPositions(UnityLineRendererPositions.ToArray());
}
else
{
FastLineRenderer r = FastLineRenderer.CreateWithParent(null, LineRenderer);
r.Material.EnableKeyword("DISABLE_CAPS");
r.SetCapacity(FastLineRenderer.MaxLinesPerMesh * FastLineRenderer.VerticesPerLine);
FastLineRendererProperties props = new FastLineRendererProperties();
for (int j = 0; j < FastLineRenderer.MaxLinesPerMesh; j++)
{
Color32 randColor = new Color32(RandomByte(), RandomByte(), RandomByte(), RandomByte());
Vector3 pos = new Vector3(UnityEngine.Random.Range(0.0f, Screen.width), UnityEngine.Random.Range(0.0f, Screen.height), UnityEngine.Random.Range(-400.0f, 400.0f));
props.Start = pos;
props.Color = randColor;
props.Radius = UnityEngine.Random.Range(1.0f, 4.0f);
props.SetLifeTime(float.MaxValue);
props.AngularVelocity = UnityEngine.Random.Range(-6.0f, 6.0f);
props.Velocity = RandomVelocity(50.0f);
r.AppendLine(props);
}
r.Apply(true);
}

LineCountLabel.text = "Lines: " + (lineCount += FastLineRenderer.MaxLinesPerMesh);
}
}

public void UseUnityLineRendererToggled()
{
FastLineRenderer.ResetAll();
UnityLineRendererPositions.Clear();
UnityLineRenderer.SetVertexCount(0);
LineCountLabel.text = string.Empty;
lineCount = 0;
}

public static float ClampAngle(float angle, float min, float max)
{
if (angle < -360F)
{
angle += 360F;
}
if (angle > 360F)
{
angle -= 360F;
}

return Mathf.Clamp(angle, min, max);
}
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.