Added Trail Effect library.

This commit is contained in:
Alex.Kirel 2023-07-26 16:38:51 +05:00
parent d9327b9595
commit cdcb4f1781
91 changed files with 2862 additions and 0 deletions

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 6a726ba0fdae4d440984f5fdb4733d17
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: f8269202cdc317242afb02d19b41b357
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 35bda278aee224f419e59e01d4a4ff06
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,28 @@
using UnityEditor;
using UnityEngine;
using System.Collections;
using PigeonCoopToolkit.Generic.Editor;
namespace PigeonCoopToolkit.Effects.Trails.Editor
{
[InitializeOnLoad]
public class PCTKEffectsIntroDialogue
{
static PCTKEffectsIntroDialogue()
{
EditorApplication.update+=Update;
}
static void Update()
{
if (EditorPrefs.GetBool("PCTK/Effects/Trails/ShownIntroDialogue") == false)
{
IntroDialogue dialogue = EditorWindow.GetWindow<IntroDialogue>(true, "Thanks for your purchase!");
dialogue.Init(Resources.Load("PCTK/Effects/Trails/banner") as Texture2D, new Generic.VersionInformation("Better Trails", 1, 3, 0), Application.dataPath + "/PigeonCoopToolkit/__Effects (Trails) Examples/Pigeon Coop Toolkit - Effects (Trails).pdf");
EditorPrefs.SetBool("PCTK/Effects/Trails/ShownIntroDialogue",true);
}
}
}
}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 83aee9145022a53418a0c515cc492327
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -0,0 +1,19 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace PigeonCoopToolkit.Effects.Trails.Editor
{
[CustomEditor(typeof(SmokePlume))]
[CanEditMultipleObjects]
public class SmokePlumeEditor : TrailEditor_Base
{
protected override void DrawTrailSpecificGUI()
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("ConstantForce"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("RandomForceScale"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("TimeBetweenPoints"));
}
}
}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ddcb2ed96cba10e4da2cae8ff8533fda
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -0,0 +1,18 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace PigeonCoopToolkit.Effects.Trails.Editor
{
[CustomEditor(typeof(SmokeTrail))]
[CanEditMultipleObjects]
public class SmokeTrailEditor : TrailEditor_Base
{
protected override void DrawTrailSpecificGUI()
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("RandomForceScale"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("MinVertexDistance"));
}
}
}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bf32d2b00d1c88c4b91cf689b5f770c5
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -0,0 +1,17 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace PigeonCoopToolkit.Effects.Trails.Editor
{
[CustomEditor(typeof(Trail))]
[CanEditMultipleObjects]
public class TrailEditor : TrailEditor_Base
{
protected override void DrawTrailSpecificGUI()
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("MinVertexDistance"));
}
}
}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dba587684cc69dc4097b307d0bacf81d
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -0,0 +1,113 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace PigeonCoopToolkit.Effects.Trails.Editor
{
public class TrailEditor_Base : UnityEditor.Editor
{
public static TrailPreviewUtillity win;
public override void OnInspectorGUI()
{
TrailRenderer_Base t = (TrailRenderer_Base)serializedObject.targetObject;
if (t == null)
return;
float defaultLabelWidth = EditorGUIUtility.labelWidth;
float defaultFieldWidth = EditorGUIUtility.fieldWidth;
GUILayout.Space(5);
GUILayout.BeginVertical();
EditorGUILayout.PropertyField(serializedObject.FindProperty("TrailData.Lifetime"));
EditorGUIUtility.labelWidth = defaultLabelWidth;
EditorGUIUtility.fieldWidth = defaultFieldWidth;
GUILayout.BeginHorizontal();
EditorGUIUtility.fieldWidth = defaultLabelWidth - 80;
EditorGUILayout.PropertyField(serializedObject.FindProperty("TrailData.TrailMaterial"));
GUILayout.Space(10);
EditorGUIUtility.labelWidth = 30;
EditorGUIUtility.fieldWidth = 40;
EditorGUILayout.PropertyField(serializedObject.FindProperty("TrailData.MaterialTileLength"), new GUIContent("Tile"), GUILayout.Width(70));
GUILayout.EndHorizontal();
EditorGUIUtility.labelWidth = defaultLabelWidth;
EditorGUIUtility.fieldWidth = defaultFieldWidth;
GUILayout.BeginHorizontal();
EditorGUIUtility.fieldWidth = defaultLabelWidth - 80;
EditorGUILayout.PropertyField(serializedObject.FindProperty("TrailData.SizeOverLife"));
GUILayout.Space(10);
EditorGUIUtility.labelWidth = 50;
EditorGUIUtility.fieldWidth = 20;
EditorGUILayout.PropertyField(serializedObject.FindProperty("TrailData.StretchSizeToFit"), new GUIContent("Stretch"), GUILayout.Width(70));
GUILayout.EndHorizontal();
EditorGUIUtility.labelWidth = defaultLabelWidth;
EditorGUIUtility.fieldWidth = defaultFieldWidth;
GUILayout.BeginHorizontal();
EditorGUIUtility.fieldWidth = defaultLabelWidth - 80;
EditorGUILayout.PropertyField(serializedObject.FindProperty("TrailData.ColorOverLife"));
GUILayout.Space(10);
EditorGUIUtility.labelWidth = 50;
EditorGUIUtility.fieldWidth = 20;
EditorGUILayout.PropertyField(serializedObject.FindProperty("TrailData.StretchColorToFit"), new GUIContent("Stretch"), GUILayout.Width(70));
GUILayout.EndHorizontal();
EditorGUIUtility.labelWidth = defaultLabelWidth;
EditorGUIUtility.fieldWidth = defaultFieldWidth;
EditorGUILayout.PropertyField(serializedObject.FindProperty("TrailData.UseForwardOverride"));
if(t.TrailData.UseForwardOverride)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("TrailData.ForwardOverride"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("TrailData.ForwardOverrideRelative"), new GUIContent("Override Relative"));
EditorGUI.indentLevel--;
}
DrawTrailSpecificGUI();
EditorGUILayout.PropertyField(serializedObject.FindProperty("MaxNumberOfPoints"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("Emit"));
GUILayout.EndVertical();
serializedObject.ApplyModifiedProperties();
serializedObject.UpdateIfDirtyOrScript();
GUILayout.Space(5);
if (GUILayout.Button("Open preview"))
{
// Get existing open window or if none, make a new one:
win = (TrailPreviewUtillity)EditorWindow.GetWindow(typeof(TrailPreviewUtillity), true, "Normalized Trail Preview");
win.minSize = new Vector2(900, 140);
win.maxSize = new Vector2(900, 140);
win.Trail = t;
}
}
protected virtual void DrawTrailSpecificGUI()
{}
}
}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0ab5f16befc58ca4bbfb8159ae3ead06
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -0,0 +1,275 @@
using UnityEngine;
using UnityEditor;
namespace PigeonCoopToolkit.Effects.Trails.Editor
{
public class TrailPreviewUtillity : EditorWindow
{
public TrailRenderer_Base Trail;
void Update()
{
if (Trail == null || Trail.TrailData == null || Selection.activeGameObject != Trail.gameObject)
{
Close();
return;
}
Repaint();
}
void OnGUI()
{
if (Trail == null || Trail.TrailData == null)
{
return;
}
GUIStyle blackBG = new GUIStyle();
blackBG.normal.background = EditorGUIUtility.whiteTexture;
blackBG.normal.textColor = Color.white;
Color revertTo = GUI.color;
float highPoint = 0;
for (int i = 0; i < 100; i++)
{
float s = Trail.TrailData.SizeOverLife.Evaluate((float)i / (float)100);
if (highPoint < s)
highPoint = s;
}
GUI.color = new Color(0.3f,0.3f,0.3f,1);
GUILayout.BeginArea(new Rect(0, 0, position.width, position.height), blackBG);
float xPos = 0;
float increment = 101;
float modulo = 303;
while (xPos * increment < position.width)
{
xPos++;
DrawLine(Vector2.right * (xPos * increment), Vector2.right * (xPos * increment) + Vector2.up * position.height, xPos * increment % modulo == 0 ? new Color(1, 1, 1, 0.1f) : new Color(1, 1, 1, 0.025f), 1);
}
DrawLine(Vector2.up * position.height / 2, Vector2.right * position.width + Vector2.up * position.height / 2, new Color(1, 1, 1, 0.1f), 1);
GL.PushMatrix();
GL.LoadPixelMatrix(-0.5f, 0.5f, 0.5f, -0.5f);
if (Trail.TrailData.TrailMaterial != null)
Trail.TrailData.TrailMaterial.SetPass(0);
GL.Begin(GL.TRIANGLE_STRIP);
InsertTriangle(0, 1);
for (int i = 0; i < 100; i++)
{
InsertTriangle((float)i / (float)100, highPoint * 2);
}
GL.End();
GL.PopMatrix();
GUILayout.EndArea();
if (Trail.TrailData.TrailMaterial == null)
{
GUILayout.BeginVertical();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.color = new Color(0, 0, 0, 0.15f);
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.BeginVertical(blackBG);
GUI.color = Color.white;
GUILayout.Label("Material is NULL", EditorStyles.whiteMiniLabel);
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.EndVertical();
}
else
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUI.color = new Color(0, 0, 0, 0.15f);
GUILayout.BeginVertical(blackBG);
GUI.color = Color.white;
GUILayout.Label("Start", EditorStyles.whiteMiniLabel);
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUI.color = new Color(0, 0, 0, 0.15f);
GUILayout.BeginVertical(blackBG);
GUI.color = Color.white;
GUILayout.Label("End", EditorStyles.whiteMiniLabel);
GUILayout.EndVertical();
GUILayout.EndHorizontal();
GUILayout.EndVertical();
}
GUI.color = revertTo;
}
void InsertTriangle(float t, float scaler)
{
if(scaler <= 0)
return;
Color c = Trail.TrailData.ColorOverLife.Evaluate(t);
float s = Trail.TrailData.SizeOverLife.Evaluate(t) / (scaler);
GL.Color(c);
GL.Vertex3(t, 0.5f + s, 0);
GL.MultiTexCoord(0, Trail.TrailData.MaterialTileLength > 0 ? new Vector3((t * position.width) / (300 * Trail.TrailData.MaterialTileLength), 0, 0) : new Vector3(t, 0, 0));
GL.Vertex3(t, 0.5f - s, 0);
GL.MultiTexCoord(0, Trail.TrailData.MaterialTileLength > 0 ? new Vector3((t * position.width) / (300 * Trail.TrailData.MaterialTileLength), 1, 0) : new Vector3(t, 1, 0));
}
public static void DrawLine(Vector2 start, Vector2 end, Color color, float width)
{
if (Event.current == null)
return;
if (Event.current.type != EventType.repaint)
return;
CreateMaterial();
lineMaterial.SetPass(0);
Vector3 startPt;
Vector3 endPt;
if (width == 1)
{
GL.Begin(GL.LINES);
GL.Color(color);
startPt = new Vector3(start.x, start.y, 0);
endPt = new Vector3(end.x, end.y, 0);
GL.Vertex(startPt);
GL.Vertex(endPt);
}
else
{
GL.Begin(GL.QUADS);
GL.Color(color);
startPt = new Vector3(end.y, start.x, 0);
endPt = new Vector3(start.y, end.x, 0);
Vector3 perpendicular = (startPt - endPt).normalized * width;
Vector3 v1 = new Vector3(start.x, start.y, 0);
Vector3 v2 = new Vector3(end.x, end.y, 0);
GL.Vertex(v1 - perpendicular);
GL.Vertex(v1 + perpendicular);
GL.Vertex(v2 + perpendicular);
GL.Vertex(v2 - perpendicular);
}
GL.End();
}
public static void CreateMaterial()
{
if (lineMaterial != null)
return;
Debug.Log ("Not Supported!{Unity5.0+}");
// lineMaterial = new Material("Shader \"Lines/Colored Blended\" {" +
// "SubShader { Pass { " +
// " Blend SrcAlpha OneMinusSrcAlpha " +
// " ZWrite Off Cull Off Fog { Mode Off } " +
// " BindChannels {" +
// " Bind \"vertex\", vertex Bind \"color\", color }" +
// "} } }");
// lineMaterial.hideFlags = HideFlags.HideAndDontSave;
// lineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
}
public static Material lineMaterial = null;
}
}
/*
using UnityEngine;
using UnityEditor;
namespace PigeonCoopToolkit.Effects.Trails.Editor
{
public class TrailPreviewUtillity : EditorWindow
{
public PCTrailRendererData Data;
void OnGUI()
{
if(Data == null)
{
Close();
return;
}
DrawLine(Vector2.zero, Vector2.right + Vector2.up,Color.red,1,Data.TrailMaterial);
}
public static void DrawLine(Vector2 start, Vector2 end, Color color, float width, Material m)
{
if (Event.current == null)
return;
if (Event.current.type != EventType.repaint)
return;
m.SetPass(0);
Vector3 startPt;
Vector3 endPt;
if (width == 1)
{
GL.Begin(GL.LINES);
GL.Color(color);
startPt = new Vector3(start.x, start.y, 0);
endPt = new Vector3(end.x, end.y, 0);
GL.Vertex(startPt);
GL.Vertex(endPt);
}
else
{
GL.Begin(GL.QUADS);
GL.Color(color);
startPt = new Vector3(end.y, start.x, 0);
endPt = new Vector3(start.y, end.x, 0);
Vector3 perpendicular = (startPt - endPt).normalized * width;
Vector3 v1 = new Vector3(start.x, start.y, 0);
Vector3 v2 = new Vector3(end.x, end.y, 0);
GL.Vertex(v1 - perpendicular);
GL.Vertex(v1 + perpendicular);
GL.Vertex(v2 + perpendicular);
GL.Vertex(v2 - perpendicular);
}
GL.End();
}
}
}
*/

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 34af64ac36cf82046853c1e9e5421c3b
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: e88319607f0d43843b735c35e8da7d61
folderAsset: yes
DefaultImporter:
userData:

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

@ -0,0 +1,60 @@
using PigeonCoopToolkit.Utillities;
using System;
using UnityEngine;
using Object = UnityEngine.Object;
namespace PigeonCoopToolkit.Effects.Trails
{
public class PCTrail : IDisposable
{
public CircularBuffer<PCTrailPoint> Points;
public Mesh Mesh;
public Vector3[] verticies;
public Vector3[] normals;
public Vector2[] uvs;
public Color[] colors;
public int[] indicies;
public int activePointCount;
public bool IsActiveTrail;
public int NumPoints;
public PCTrail(int numPoints)
{
this.Mesh = new Mesh();
this.Mesh.MarkDynamic();
this.verticies = new Vector3[2 * numPoints];
this.normals = new Vector3[2 * numPoints];
this.uvs = new Vector2[2 * numPoints];
this.colors = new Color[2 * numPoints];
this.indicies = new int[2 * numPoints * 3];
this.Points = new CircularBuffer<PCTrailPoint>(numPoints);
this.NumPoints = numPoints;
}
public void Dispose()
{
if (this.Mesh != null)
{
if (Application.isEditor)
{
Object.DestroyImmediate(this.Mesh, true);
}
else
{
Object.Destroy(this.Mesh);
}
}
this.Points.Clear();
this.Points = null;
}
}
}

View file

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6bdb573c1d60b9b4c9c5813da7dd36b3
timeCreated: 1510298205
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,43 @@
using System;
using UnityEngine;
namespace PigeonCoopToolkit.Effects.Trails
{
public class PCTrailPoint
{
public Vector3 Forward;
public Vector3 Position;
public int PointNumber;
private float _timeActive;
private float _distance;
public virtual void Update(float deltaTime)
{
this._timeActive += deltaTime;
}
public float TimeActive()
{
return this._timeActive;
}
public void SetTimeActive(float time)
{
this._timeActive = time;
}
public void SetDistanceFromStart(float distance)
{
this._distance = distance;
}
public float GetDistanceFromStart()
{
return this._distance;
}
}
}

View file

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d1183b720c636c54187be6b54124b9d8
timeCreated: 1510298399
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,41 @@
using System;
using UnityEngine;
namespace PigeonCoopToolkit.Effects.Trails
{
[Serializable]
public class PCTrailRendererData
{
public Material TrailMaterial;
public float Lifetime = 1f;
public bool UsingSimpleSize;
public float SimpleSizeOverLifeStart;
public float SimpleSizeOverLifeEnd;
public AnimationCurve SizeOverLife = new AnimationCurve();
public bool UsingSimpleColor;
public Color SimpleColorOverLifeStart;
public Color SimpleColorOverLifeEnd;
public Gradient ColorOverLife;
public bool StretchSizeToFit;
public bool StretchColorToFit;
public float MaterialTileLength;
public bool UseForwardOverride;
public Vector3 ForwardOverride;
public bool ForwardOverrideRelative;
}
}

View file

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2df86c9fa942e934f8d1b47514ebeeca
timeCreated: 1510298132
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 6f284d34362cfbd4dac1f041e217159f
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: cb26a4a5e9479484ea1e4015d6117887
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: f4c3d22dfd9259b47bd18e2fbb40a661
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 9c92f0fb3caf95948bab8c97c7c38a7d
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
namespace PigeonCoopToolkit.Effects.Trails
{
[AddComponentMenu("Pigeon Coop Toolkit/Effects/Smoke Plume")]
public class SmokePlume : TrailRenderer_Base
{
public float TimeBetweenPoints = 0.1f;
public Vector3 ConstantForce = Vector3.up * 0.5f;
public float RandomForceScale = 0.05f;
public int MaxNumberOfPoints = 50;
private float _timeSincePoint;
protected void OnEnable()
{
base.Start();
base.ClearSystem(true);
this._timeSincePoint = 0f;
}
protected override void OnStartEmit()
{
this._timeSincePoint = 0f;
}
protected override void Reset()
{
base.Reset();
this.TrailData.SizeOverLife = new AnimationCurve(new Keyframe[]
{
new Keyframe(0f, 0f),
new Keyframe(0.5f, 0.2f),
new Keyframe(1f, 0.2f)
});
this.TrailData.Lifetime = 6f;
this.ConstantForce = Vector3.up * 0.5f;
this.TimeBetweenPoints = 0.1f;
this.RandomForceScale = 0.05f;
this.MaxNumberOfPoints = 50;
}
protected override void Update()
{
if (this._emit)
{
this._timeSincePoint += (this._noDecay ? 0f : Time.deltaTime);
if (this._timeSincePoint >= this.TimeBetweenPoints)
{
base.AddPoint(new SmokeTrailPoint(), this._t.position);
this._timeSincePoint = 0f;
}
}
base.Update();
}
protected override void InitialiseNewPoint(PCTrailPoint newPoint)
{
((SmokeTrailPoint)newPoint).RandomVec = Random.onUnitSphere * this.RandomForceScale;
}
protected override void UpdateTrail(PCTrail trail, float deltaTime)
{
if (this._noDecay)
{
return;
}
using IEnumerator<PCTrailPoint> enumerator = trail.Points.GetEnumerator();
while (enumerator.MoveNext())
{
PCTrailPoint current = enumerator.Current;
current.Position += this.ConstantForce * deltaTime;
}
}
protected override int GetMaxNumberOfPoints()
{
return this.MaxNumberOfPoints;
}
}
}

View file

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9150799c728c3564980a1475e0a0808c
timeCreated: 1510298265
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,70 @@
using System;
using UnityEngine;
using Random = UnityEngine.Random;
namespace PigeonCoopToolkit.Effects.Trails
{
[AddComponentMenu("Pigeon Coop Toolkit/Effects/Smoke Trail")]
public class SmokeTrail : TrailRenderer_Base
{
public float MinVertexDistance = 0.1f;
public int MaxNumberOfPoints = 50;
private Vector3 _lastPosition;
private float _distanceMoved;
public float RandomForceScale = 1f;
protected void OnEnable()
{
base.Start();
base.ClearSystem(true);
this._lastPosition = this._t.position;
}
protected override void Update()
{
if (this._emit)
{
this._distanceMoved += Vector3.Distance(this._t.position, this._lastPosition);
if (this._distanceMoved != 0f && this._distanceMoved >= this.MinVertexDistance)
{
base.AddPoint(new SmokeTrailPoint(), this._t.position);
this._distanceMoved = 0f;
}
this._lastPosition = this._t.position;
}
base.Update();
}
protected override void OnStartEmit()
{
this._lastPosition = this._t.position;
this._distanceMoved = 0f;
}
protected override void Reset()
{
base.Reset();
this.MinVertexDistance = 0.1f;
this.RandomForceScale = 1f;
}
protected override void InitialiseNewPoint(PCTrailPoint newPoint)
{
((SmokeTrailPoint)newPoint).RandomVec = Random.onUnitSphere * this.RandomForceScale;
}
protected override void OnTranslate(Vector3 t)
{
this._lastPosition += t;
}
protected override int GetMaxNumberOfPoints()
{
return this.MaxNumberOfPoints;
}
}
}

View file

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e6e5843f68b0854409013b4b9196c5fd
timeCreated: 1510298456
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,16 @@
using System;
using UnityEngine;
namespace PigeonCoopToolkit.Effects.Trails
{
public class SmokeTrailPoint : PCTrailPoint
{
public Vector3 RandomVec;
public override void Update(float deltaTime)
{
base.Update(deltaTime);
this.Position += this.RandomVec * deltaTime;
}
}
}

View file

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2cd086e711bdc064f8bc07309eedeb68
timeCreated: 1510298131
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,188 @@
using PigeonCoopToolkit.Utillities;
using System;
using UnityEngine;
namespace PigeonCoopToolkit.Effects.Trails
{
[AddComponentMenu("Pigeon Coop Toolkit/Effects/Smooth Trail")]
public class SmoothTrail : TrailRenderer_Base
{
private class ControlPoint
{
public Vector3 p;
public Vector3 forward;
}
public float MinControlPointDistance = 0.1f;
public int MaxControlPoints = 15;
public int PointsBetweenControlPoints = 4;
private Vector3 _lastPosition;
private float _distanceMoved;
private CircularBuffer<SmoothTrail.ControlPoint> _controlPoints;
protected void OnEnable()
{
base.Start();
base.ClearSystem(true);
this._lastPosition = this._t.position;
}
protected override void Update()
{
if (this._emit)
{
this._distanceMoved += Vector3.Distance(this._t.position, this._lastPosition);
if (!Mathf.Approximately(this._distanceMoved, 0f) && this._distanceMoved >= this.MinControlPointDistance)
{
this.AddControlPoint(this._t.position);
this._distanceMoved = 0f;
}
else
{
this._controlPoints[this._controlPoints.Count - 1].p = this._t.position;
if (this.TrailData.UseForwardOverride)
{
this._controlPoints[this._controlPoints.Count - 1].forward = (this.TrailData.ForwardOverrideRelative ? this._t.TransformDirection(this.TrailData.ForwardOverride.normalized) : this.TrailData.ForwardOverride.normalized);
}
}
this._lastPosition = this._t.position;
}
base.Update();
}
protected override void OnStartEmit()
{
this._lastPosition = this._t.position;
this._distanceMoved = 0f;
this._controlPoints = new CircularBuffer<SmoothTrail.ControlPoint>(this.MaxControlPoints);
this._controlPoints.Add(new SmoothTrail.ControlPoint
{
p = this._lastPosition
});
if (this.TrailData.UseForwardOverride)
{
this._controlPoints[0].forward = (this.TrailData.ForwardOverrideRelative ? this._t.TransformDirection(this.TrailData.ForwardOverride.normalized) : this.TrailData.ForwardOverride.normalized);
}
base.AddPoint(new PCTrailPoint(), this._lastPosition);
this.AddControlPoint(this._lastPosition);
}
protected override void UpdateTrail(PCTrail trail, float deltaTime)
{
if (!trail.IsActiveTrail)
{
return;
}
int num = 0;
for (int i = 0; i < this._controlPoints.Count; i++)
{
trail.Points[num].Position = this._controlPoints[i].p;
if (this.TrailData.UseForwardOverride)
{
trail.Points[num].Forward = this._controlPoints[i].forward;
}
num++;
if (i < this._controlPoints.Count - 1)
{
float d = Vector3.Distance(this._controlPoints[i].p, this._controlPoints[i + 1].p) / 2f;
Vector3 curveStartHandle;
if (i == 0)
{
curveStartHandle = this._controlPoints[i].p + (this._controlPoints[i + 1].p - this._controlPoints[i].p).normalized * d;
}
else
{
curveStartHandle = this._controlPoints[i].p + (this._controlPoints[i + 1].p - this._controlPoints[i - 1].p).normalized * d;
}
int num2 = i + 1;
Vector3 curveEndHandle;
if (num2 == this._controlPoints.Count - 1)
{
curveEndHandle = this._controlPoints[num2].p + (this._controlPoints[num2 - 1].p - this._controlPoints[num2].p).normalized * d;
}
else
{
curveEndHandle = this._controlPoints[num2].p + (this._controlPoints[num2 - 1].p - this._controlPoints[num2 + 1].p).normalized * d;
}
PCTrailPoint pCTrailPoint = trail.Points[num - 1];
PCTrailPoint pCTrailPoint2 = trail.Points[num - 1 + this.PointsBetweenControlPoints + 1];
for (int j = 0; j < this.PointsBetweenControlPoints; j++)
{
float t = ((float)j + 1f) / ((float)this.PointsBetweenControlPoints + 1f);
trail.Points[num].Position = this.GetPointAlongCurve(this._controlPoints[i].p, curveStartHandle, this._controlPoints[i + 1].p, curveEndHandle, t, 0.3f);
trail.Points[num].SetTimeActive(Mathf.Lerp(pCTrailPoint.TimeActive(), pCTrailPoint2.TimeActive(), t));
if (this.TrailData.UseForwardOverride)
{
trail.Points[num].Forward = Vector3.Lerp(pCTrailPoint.Forward, pCTrailPoint2.Forward, t);
}
num++;
}
}
}
int num3 = this._controlPoints.Count - 1 + (this._controlPoints.Count - 1) * this.PointsBetweenControlPoints;
int num4 = num3 - this.PointsBetweenControlPoints - 1;
int num5 = num3 + 1;
float num6 = trail.Points[num4].GetDistanceFromStart();
for (int k = num4 + 1; k < num5; k++)
{
num6 += Vector3.Distance(trail.Points[k - 1].Position, trail.Points[k].Position);
trail.Points[k].SetDistanceFromStart(num6);
}
}
protected override void Reset()
{
base.Reset();
this.MinControlPointDistance = 0.1f;
this.MaxControlPoints = 15;
this.PointsBetweenControlPoints = 4;
}
protected override void OnTranslate(Vector3 t)
{
this._lastPosition += t;
for (int i = 0; i < this._controlPoints.Count; i++)
{
this._controlPoints[i].p += t;
}
}
private void AddControlPoint(Vector3 position)
{
for (int i = 0; i < this.PointsBetweenControlPoints; i++)
{
base.AddPoint(new PCTrailPoint(), position);
}
base.AddPoint(new PCTrailPoint(), position);
SmoothTrail.ControlPoint controlPoint = new SmoothTrail.ControlPoint
{
p = position
};
if (this.TrailData.UseForwardOverride)
{
controlPoint.forward = (this.TrailData.ForwardOverrideRelative ? this._t.TransformDirection(this.TrailData.ForwardOverride.normalized) : this.TrailData.ForwardOverride.normalized);
}
this._controlPoints.Add(controlPoint);
}
protected override int GetMaxNumberOfPoints()
{
return this.MaxControlPoints + this.MaxControlPoints * this.PointsBetweenControlPoints;
}
public Vector3 GetPointAlongCurve(Vector3 curveStart, Vector3 curveStartHandle, Vector3 curveEnd, Vector3 curveEndHandle, float t, float crease)
{
float num = 1f - t;
float num2 = Mathf.Pow(num, 3f);
float num3 = Mathf.Pow(num, 2f);
float num4 = 1f - crease;
return (num2 * curveStart * num4 + 3f * num3 * t * curveStartHandle * crease + 3f * num * Mathf.Pow(t, 2f) * curveEndHandle * crease + Mathf.Pow(t, 3f) * curveEnd * num4) / (num2 * num4 + 3f * num3 * t * crease + 3f * num * Mathf.Pow(t, 2f) * crease + Mathf.Pow(t, 3f) * num4);
}
}
}

View file

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fd5b6425a33ee3749a6a773b54f07066
timeCreated: 1510298520
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,61 @@
using System;
using UnityEngine;
namespace PigeonCoopToolkit.Effects.Trails
{
[AddComponentMenu("Pigeon Coop Toolkit/Effects/Trail")]
public class Trail : TrailRenderer_Base
{
public float MinVertexDistance = 0.1f;
public int MaxNumberOfPoints = 50;
private Vector3 _lastPosition;
private float _distanceMoved;
public void OnEnable()
{
base.Start();
base.ClearSystem(true);
this._lastPosition = this._t.position;
}
protected override void Update()
{
if (this._emit)
{
this._distanceMoved += Vector3.Distance(this._t.position, this._lastPosition);
if (this._distanceMoved != 0f && this._distanceMoved >= this.MinVertexDistance)
{
base.AddPoint(new PCTrailPoint(), this._t.position);
this._distanceMoved = 0f;
}
this._lastPosition = this._t.position;
}
base.Update();
}
protected override void OnStartEmit()
{
this._lastPosition = this._t.position;
this._distanceMoved = 0f;
}
protected override void Reset()
{
base.Reset();
this.MinVertexDistance = 0.1f;
}
protected override void OnTranslate(Vector3 t)
{
this._lastPosition += t;
}
protected override int GetMaxNumberOfPoints()
{
return this.MaxNumberOfPoints;
}
}
}

View file

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3f6ff3d33c169d34ca9bc146f4ef62ce
timeCreated: 1510298149
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,512 @@
using System;
using System.Collections.Generic;
using PigeonCoopToolkit.Utillities;
using UnityEngine;
using Object = UnityEngine.Object;
namespace PigeonCoopToolkit.Effects.Trails
{
public abstract class TrailRenderer_Base : MonoBehaviour
{
public PCTrailRendererData TrailData;
public bool Emit;
protected bool _emit;
protected bool _noDecay;
private PCTrail _activeTrail;
private List<PCTrail> _fadingTrails;
protected Transform _t;
private static Dictionary<Material, List<PCTrail>> _matToTrailList;
private static List<Mesh> _toClean;
private static bool _hasRenderer;
private static int GlobalTrailRendererCount;
protected virtual void Awake()
{
GlobalTrailRendererCount++;
if (GlobalTrailRendererCount == 1)
{
_matToTrailList = new Dictionary<Material, List<PCTrail>>();
_toClean = new List<Mesh>();
}
_fadingTrails = new List<PCTrail>();
_t = transform;
_emit = Emit;
if (_emit)
{
_activeTrail = new PCTrail(GetMaxNumberOfPoints());
_activeTrail.IsActiveTrail = true;
OnStartEmit();
}
}
protected virtual void Start()
{
}
protected virtual void LateUpdate()
{
if (_hasRenderer)
{
return;
}
_hasRenderer = true;
foreach (KeyValuePair<Material, List<PCTrail>> current in _matToTrailList)
{
CombineInstance[] array = new CombineInstance[current.Value.Count];
for (int i = 0; i < current.Value.Count; i++)
{
array[i] = new CombineInstance
{
mesh = current.Value[i].Mesh,
subMeshIndex = 0,
transform = Matrix4x4.identity
};
}
Mesh mesh = new Mesh();
mesh.CombineMeshes(array, true, false);
_toClean.Add(mesh);
DrawMesh(mesh, current.Key);
current.Value.Clear();
}
}
protected virtual void Update()
{
if (_hasRenderer)
{
_hasRenderer = false;
if (_toClean.Count > 0)
{
for (int i = 0; i < _toClean.Count; i++)
{
Mesh mesh = _toClean[i];
if (mesh != null)
{
if (Application.isEditor)
{
Object.DestroyImmediate(mesh, true);
}
else
{
Object.Destroy(mesh);
}
}
}
}
_toClean.Clear();
}
if (!_matToTrailList.ContainsKey(TrailData.TrailMaterial))
{
_matToTrailList.Add(TrailData.TrailMaterial, new List<PCTrail>());
}
if (_activeTrail != null)
{
UpdatePoints(_activeTrail, Time.deltaTime);
UpdateTrail(_activeTrail, Time.deltaTime);
GenerateMesh(_activeTrail);
_matToTrailList[TrailData.TrailMaterial].Add(_activeTrail);
}
for (int j = _fadingTrails.Count - 1; j >= 0; j--)
{
if (_fadingTrails[j] == null || !AnyElement(_fadingTrails[j].Points))
{
if (_fadingTrails[j] != null)
{
_fadingTrails[j].Dispose();
}
_fadingTrails.RemoveAt(j);
}
else
{
UpdatePoints(_fadingTrails[j], Time.deltaTime);
UpdateTrail(_fadingTrails[j], Time.deltaTime);
GenerateMesh(_fadingTrails[j]);
_matToTrailList[TrailData.TrailMaterial].Add(_fadingTrails[j]);
}
}
CheckEmitChange();
}
protected bool AnyElement(CircularBuffer<PCTrailPoint> InPoints)
{
for (int i = 0; i < InPoints.Count; i++)
{
PCTrailPoint pCTrailPoint = InPoints[i];
if (pCTrailPoint.TimeActive() < TrailData.Lifetime)
{
return true;
}
}
return false;
}
protected virtual void OnDestroy()
{
GlobalTrailRendererCount--;
if (GlobalTrailRendererCount == 0)
{
if (_toClean != null && _toClean.Count > 0)
{
for (int i = 0; i < _toClean.Count; i++)
{
Mesh mesh = _toClean[i];
if (mesh != null)
{
if (Application.isEditor)
{
Object.DestroyImmediate(mesh, true);
}
else
{
Object.Destroy(mesh);
}
}
}
}
_toClean = null;
_matToTrailList.Clear();
_matToTrailList = null;
}
if (_activeTrail != null)
{
_activeTrail.Dispose();
_activeTrail = null;
}
if (_fadingTrails != null)
{
for (int j = 0; j < _fadingTrails.Count; j++)
{
PCTrail pCTrail = _fadingTrails[j];
if (pCTrail != null)
{
pCTrail.Dispose();
}
}
_fadingTrails.Clear();
}
}
protected virtual void OnStopEmit()
{
}
protected virtual void OnStartEmit()
{
}
protected virtual void OnTranslate(Vector3 t)
{
}
protected abstract int GetMaxNumberOfPoints();
protected virtual void Reset()
{
if (TrailData == null)
{
TrailData = new PCTrailRendererData();
}
TrailData.Lifetime = 1f;
TrailData.UsingSimpleColor = false;
TrailData.UsingSimpleSize = false;
TrailData.ColorOverLife = new Gradient();
TrailData.SimpleColorOverLifeStart = Color.white;
TrailData.SimpleColorOverLifeEnd = new Color(1f, 1f, 1f, 0f);
TrailData.SizeOverLife = new AnimationCurve(new Keyframe(0f, 1f), new Keyframe(1f, 0f));
TrailData.SimpleSizeOverLifeStart = 1f;
TrailData.SimpleSizeOverLifeEnd = 0f;
}
protected virtual void InitialiseNewPoint(PCTrailPoint newPoint)
{
}
protected virtual void UpdateTrail(PCTrail trail, float deltaTime)
{
}
protected void AddPoint(PCTrailPoint newPoint, Vector3 pos)
{
if (_activeTrail == null)
{
return;
}
newPoint.Position = pos;
newPoint.PointNumber = ((_activeTrail.Points.Count == 0) ? 0 : (_activeTrail.Points[_activeTrail.Points.Count - 1].PointNumber + 1));
InitialiseNewPoint(newPoint);
newPoint.SetDistanceFromStart((_activeTrail.Points.Count == 0) ? 0f : (_activeTrail.Points[_activeTrail.Points.Count - 1].GetDistanceFromStart() + Vector3.Distance(_activeTrail.Points[_activeTrail.Points.Count - 1].Position, pos)));
if (TrailData.UseForwardOverride)
{
newPoint.Forward = (TrailData.ForwardOverrideRelative ? _t.TransformDirection(TrailData.ForwardOverride.normalized) : TrailData.ForwardOverride.normalized);
}
_activeTrail.Points.Add(newPoint);
}
private void GenerateMesh(PCTrail trail)
{
trail.Mesh.Clear(false);
Vector3 vector = (Camera.main != null) ? Camera.main.transform.forward : Vector3.forward;
if (TrailData.UseForwardOverride)
{
vector = TrailData.ForwardOverride.normalized;
}
trail.activePointCount = NumberOfActivePoints(trail);
if (trail.activePointCount < 2)
{
return;
}
int num = 0;
for (int i = 0; i < trail.Points.Count; i++)
{
PCTrailPoint pCTrailPoint = trail.Points[i];
float num2 = pCTrailPoint.TimeActive() / TrailData.Lifetime;
if (pCTrailPoint.TimeActive() <= TrailData.Lifetime)
{
if (TrailData.UseForwardOverride && TrailData.ForwardOverrideRelative)
{
vector = pCTrailPoint.Forward;
}
Vector3 a = Vector3.zero;
a = i < trail.Points.Count - 1 ? Vector3.Cross((trail.Points[i + 1].Position - pCTrailPoint.Position).normalized, vector).normalized : Vector3.Cross((pCTrailPoint.Position - trail.Points[i - 1].Position).normalized, vector).normalized;
Color color = TrailData.StretchColorToFit ? (TrailData.UsingSimpleColor ? Color.Lerp(TrailData.SimpleColorOverLifeStart, TrailData.SimpleColorOverLifeEnd, 1f - num / (float)trail.activePointCount / 2f) : TrailData.ColorOverLife.Evaluate(1f - num / (float)trail.activePointCount / 2f)) : (TrailData.UsingSimpleColor ? Color.Lerp(TrailData.SimpleColorOverLifeStart, TrailData.SimpleColorOverLifeEnd, num2) : TrailData.ColorOverLife.Evaluate(num2));
float d = TrailData.StretchSizeToFit ? (TrailData.UsingSimpleSize ? Mathf.Lerp(TrailData.SimpleSizeOverLifeStart, TrailData.SimpleSizeOverLifeEnd, 1f - num / (float)trail.activePointCount / 2f) : TrailData.SizeOverLife.Evaluate(1f - num / (float)trail.activePointCount / 2f)) : (TrailData.UsingSimpleSize ? Mathf.Lerp(TrailData.SimpleSizeOverLifeStart, TrailData.SimpleSizeOverLifeEnd, num2) : TrailData.SizeOverLife.Evaluate(num2));
trail.verticies[num] = pCTrailPoint.Position + a * d;
if (TrailData.MaterialTileLength <= 0f)
{
trail.uvs[num] = new Vector2(num / (float)trail.activePointCount / 2f, 0f);
}
else
{
trail.uvs[num] = new Vector2(pCTrailPoint.GetDistanceFromStart() / TrailData.MaterialTileLength, 0f);
}
trail.normals[num] = vector;
trail.colors[num] = color;
num++;
trail.verticies[num] = pCTrailPoint.Position - a * d;
if (TrailData.MaterialTileLength <= 0f)
{
trail.uvs[num] = new Vector2(num / (float)trail.activePointCount / 2f, 1f);
}
else
{
trail.uvs[num] = new Vector2(pCTrailPoint.GetDistanceFromStart() / TrailData.MaterialTileLength, 1f);
}
trail.normals[num] = vector;
trail.colors[num] = color;
num++;
}
}
Vector2 v = trail.verticies[num - 1];
for (int j = num; j < trail.verticies.Length; j++)
{
trail.verticies[j] = v;
}
int num3 = 0;
for (int k = 0; k < 2 * (trail.activePointCount - 1); k++)
{
if (k % 2 == 0)
{
trail.indicies[num3] = k;
num3++;
trail.indicies[num3] = k + 1;
num3++;
trail.indicies[num3] = k + 2;
}
else
{
trail.indicies[num3] = k + 2;
num3++;
trail.indicies[num3] = k + 1;
num3++;
trail.indicies[num3] = k;
}
num3++;
}
int num4 = trail.indicies[num3 - 1];
for (int l = num3; l < trail.indicies.Length; l++)
{
trail.indicies[l] = num4;
}
trail.Mesh.vertices = trail.verticies;
trail.Mesh.SetIndices(trail.indicies, MeshTopology.Triangles, 0);
trail.Mesh.uv = trail.uvs;
trail.Mesh.normals = trail.normals;
trail.Mesh.colors = trail.colors;
}
private void DrawMesh(Mesh trailMesh, Material trailMaterial)
{
Graphics.DrawMesh(trailMesh, Matrix4x4.identity, trailMaterial, gameObject.layer);
}
private void UpdatePoints(PCTrail line, float deltaTime)
{
for (int i = 0; i < line.Points.Count; i++)
{
line.Points[i].Update(_noDecay ? 0f : deltaTime);
}
}
[Obsolete("UpdatePoint is deprecated, you should instead override UpdateTrail and loop through the individual points yourself (See Smoke or Smoke Plume scripts for how to do this).", true)]
protected virtual void UpdatePoint(PCTrailPoint pCTrailPoint, float deltaTime)
{
}
private void CheckEmitChange()
{
if (_emit != Emit)
{
_emit = Emit;
if (_emit)
{
if (_activeTrail == null || _activeTrail.NumPoints != GetMaxNumberOfPoints())
{
if (_activeTrail != null)
{
_activeTrail.Dispose();
}
_activeTrail = new PCTrail(GetMaxNumberOfPoints());
}
else
{
_activeTrail.Points.Clear();
}
_activeTrail.IsActiveTrail = true;
OnStartEmit();
}
else
{
OnStopEmit();
_activeTrail.IsActiveTrail = false;
_fadingTrails.Add(_activeTrail);
}
}
}
private int NumberOfActivePoints(PCTrail line)
{
int num = 0;
for (int i = 0; i < line.Points.Count; i++)
{
if (line.Points[i].TimeActive() < TrailData.Lifetime)
{
num++;
}
}
return num;
}
[ContextMenu("Toggle inspector size input method")]
protected void ToggleSizeInputStyle()
{
TrailData.UsingSimpleSize = !TrailData.UsingSimpleSize;
}
[ContextMenu("Toggle inspector color input method")]
protected void ToggleColorInputStyle()
{
TrailData.UsingSimpleColor = !TrailData.UsingSimpleColor;
}
public void LifeDecayEnabled(bool enabled)
{
_noDecay = !enabled;
}
public void Translate(Vector3 t)
{
if (_activeTrail != null)
{
for (int i = 0; i < _activeTrail.Points.Count; i++)
{
_activeTrail.Points[i].Position += t;
}
}
if (_fadingTrails != null)
{
for (int j = 0; j < _fadingTrails.Count; j++)
{
PCTrail pCTrail = _fadingTrails[j];
if (pCTrail != null)
{
for (int k = 0; k < pCTrail.Points.Count; k++)
{
pCTrail.Points[k].Position += t;
}
}
}
}
OnTranslate(t);
}
public void CreateTrail(Vector3 from, Vector3 to, float distanceBetweenPoints)
{
float num = Vector3.Distance(from, to);
Vector3 normalized = (to - from).normalized;
float num2 = 0f;
CircularBuffer<PCTrailPoint> circularBuffer = new CircularBuffer<PCTrailPoint>(GetMaxNumberOfPoints());
int num3 = 0;
while (num2 < num)
{
PCTrailPoint pCTrailPoint = new PCTrailPoint();
pCTrailPoint.PointNumber = num3;
pCTrailPoint.Position = from + normalized * num2;
circularBuffer.Add(pCTrailPoint);
InitialiseNewPoint(pCTrailPoint);
num3++;
if (distanceBetweenPoints <= 0f)
{
break;
}
num2 += distanceBetweenPoints;
}
PCTrailPoint pCTrailPoint2 = new PCTrailPoint();
pCTrailPoint2.PointNumber = num3;
pCTrailPoint2.Position = to;
circularBuffer.Add(pCTrailPoint2);
InitialiseNewPoint(pCTrailPoint2);
PCTrail pCTrail = new PCTrail(GetMaxNumberOfPoints());
pCTrail.Points = circularBuffer;
_fadingTrails.Add(pCTrail);
}
public void ClearSystem(bool emitState)
{
if (_fadingTrails != null)
{
for (int i = 0; i < _fadingTrails.Count; i++)
{
PCTrail pCTrail = _fadingTrails[i];
if (pCTrail != null && pCTrail != _activeTrail)
{
pCTrail.Dispose();
}
}
_fadingTrails.Clear();
}
Emit = emitState;
_emit = !emitState;
CheckEmitChange();
}
public int NumSegments()
{
int num = 0;
if (_activeTrail != null && NumberOfActivePoints(_activeTrail) != 0)
{
num++;
}
return num + _fadingTrails.Count;
}
}
}

View file

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 21f59b203fc36464997343d7fbb43d8f
timeCreated: 1510298121
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 0a9b95943ee423546af04cdf2ca77dcb
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 4bb7bc1d04cd01a44b699141de29a4f4
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,81 @@
using UnityEditor;
using UnityEngine;
namespace PigeonCoopToolkit.Generic.Editor
{
public class IntroDialogue : EditorWindow
{
public VersionInformation versionInformation;
public Texture2D banner;
public string UserGuidePath;
void OnGUI()
{
if(banner == null)
{
return;
}
GUI.DrawTexture(new Rect(0, 0, banner.width, banner.height), banner);
GUILayout.Space(banner.height - 18);
if (versionInformation != null) GUILayout.Label(versionInformation.ToString());
GUIStyle lessPaddingNotif = new GUIStyle("NotificationText");
lessPaddingNotif.padding = new RectOffset(10,10,10,10);
lessPaddingNotif.margin = new RectOffset(10, 10, 10, 10);
lessPaddingNotif.stretchWidth = true;
GUILayout.Label("Thanks for your purchase! ♥", lessPaddingNotif);
GUILayout.BeginHorizontal();
GUILayout.Space(16);
GUILayout.BeginVertical();
GUILayout.Label("We hope you enjoy this tool. Feel free to contact us at our twitter or email - send us feature requests, get some help from us, or just say hi!", "WordWrapLabel");
GUILayout.Label("Don't forget to rate or review "+versionInformation.Name+" on the asset store once you've had a chance to evaluate it", "WordWrapLabel");
GUILayout.EndVertical();
GUILayout.Space(16);
GUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.BeginVertical();
if (!string.IsNullOrEmpty(UserGuidePath))
{
if (GUILayout.Button("Need help? Read the guide!","LargeButton"))
{
Application.OpenURL(UserGuidePath);
};
}
GUILayout.Space(5);
if (GUILayout.Button("Want to say hello? @PigeonCoopAU", "LargeButton"))
{
Application.OpenURL("http://www.twitter.com/PigeonCoopAU");
};
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Label("© 2014 Pigeon Coop ", EditorStyles.miniLabel);
}
public void Init(Texture2D _banner, VersionInformation _versionInformation, string userGuidePath)
{
banner = _banner;
UserGuidePath = userGuidePath;
if (System.IO.File.Exists(FileUtil.GetProjectRelativePath(userGuidePath)) == false)
UserGuidePath = null;
versionInformation = _versionInformation;
minSize = maxSize = new Vector2(banner.width, 500);
}
}
}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 026003e24f7b7ce43b28fc3c8a4a40bf
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: f96a53c06e3e24b4cae13070f3b8a5cd
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: ca4b996a254788e47a48279672b9f8fc
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: c3eef40730cf0864d97e8e04a0ee6f8e
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,44 @@
using UnityEngine;
namespace PigeonCoopToolkit.Generic
{
[System.Serializable]
public class VersionInformation
{
public string Name;
public int Major = 1;
public int Minor = 0;
public int Patch = 0;
public VersionInformation(string name, int major, int minor, int patch)
{
Name = name;
Major = major;
Minor = minor;
Patch = patch;
}
public override string ToString()
{
return string.Format("{0} {1}.{2}.{3}", Name, Major, Minor, Patch);
}
public bool Match(VersionInformation other, bool looseMatch)
{
if(looseMatch)
{
return other.Name == Name &&
other.Major == Major &&
other.Minor == Minor;
}
else
{
return other.Name == Name &&
other.Major == Major &&
other.Minor == Minor &&
other.Patch == Patch;
}
}
}
}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1d58a7e753bea0e4c84779d092563363
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: ed403bda32d6d8b4abc0e3a2de4b8fa1
folderAsset: yes
timeCreated: 1497081290
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,40 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Arrow
m_Shader: {fileID: 200, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _DecalTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: 9e6a712ea43474b4ca7d6dc2984f9e2d, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _InvFade
second: 1
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _TintColor
second: {r: 1, g: 1, b: 1, a: 1}

View file

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: bf90f05c17802054f98f9b5f331d8953
NativeFormatImporter:
userData:

View file

@ -0,0 +1,52 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: BarrelSmoke
m_Shader: {fileID: 203, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _BumpMap
second:
m_Texture: {fileID: 2800000, guid: 984639d35625032479433f0f906a8bda, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: 98450d1e53061f840886062fc42513fa, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _Cutoff
second: 0.5589286
- first:
name: _InvFade
second: 0.01
- first:
name: _Shininess
second: 0.70927906
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 0.02745098}
- first:
name: _EmisColor
second: {r: 0.2, g: 0.2, b: 0.2, a: 0}
- first:
name: _SpecColor
second: {r: 0.1397059, g: 0.1397059, b: 0.1397059, a: 1}
- first:
name: _TintColor
second: {r: 1, g: 1, b: 1, a: 0.19607843}

View file

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 2c45238b0e8e5b443a693d7c92c89d3e
NativeFormatImporter:
userData:

View file

@ -0,0 +1,52 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: FlameSwordTrail
m_Shader: {fileID: 200, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _BumpMap
second:
m_Texture: {fileID: 2800000, guid: 984639d35625032479433f0f906a8bda, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: 98450d1e53061f840886062fc42513fa, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _Cutoff
second: 0.4464286
- first:
name: _InvFade
second: 0.3592857
- first:
name: _Shininess
second: 0.70927906
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _EmisColor
second: {r: 0.2, g: 0.2, b: 0.2, a: 0}
- first:
name: _SpecColor
second: {r: 0.1397059, g: 0.1397059, b: 0.1397059, a: 1}
- first:
name: _TintColor
second: {r: 1, g: 0.88965523, b: 0, a: 1}

View file

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: a6c0d0c41df93a243b0e594e935d9a86
NativeFormatImporter:
userData:

View file

@ -0,0 +1,34 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: LowPolyTankTextureTreadDecal
m_Shader: {fileID: 203, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: ab6d9a235b23c874885a173a6a2aa027, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _InvFade
second: 1
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _TintColor
second: {r: 0.3455882, g: 0.22165315, b: 0, a: 0.5019608}

View file

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 0e0449aa4e0e216479ba4ebbe28e8288
NativeFormatImporter:
userData:

View file

@ -0,0 +1,52 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: MuzzleFlash
m_Shader: {fileID: 200, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _BumpMap
second:
m_Texture: {fileID: 2800000, guid: 984639d35625032479433f0f906a8bda, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: 98450d1e53061f840886062fc42513fa, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _Cutoff
second: 0.4464286
- first:
name: _InvFade
second: 1
- first:
name: _Shininess
second: 0.70927906
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _EmisColor
second: {r: 0.2, g: 0.2, b: 0.2, a: 0}
- first:
name: _SpecColor
second: {r: 0.1397059, g: 0.1397059, b: 0.1397059, a: 1}
- first:
name: _TintColor
second: {r: 0.69411767, g: 0.69411767, b: 0.69411767, a: 0.19607843}

View file

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 43839268c81ec7340b2eb815c164e0dd
NativeFormatImporter:
userData:

View file

@ -0,0 +1,37 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: SelectionTrail
m_Shader: {fileID: 4800000, guid: c105fca0e8365434ab3e97e8a6979893, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: 62418b70010db0749956023a9435a814, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: PixelSnap
second: 0
- first:
name: _InvFade
second: 1
m_Colors:
- first:
name: _Color
second: {r: 0.8095238, g: 1, b: 0, a: 1}
- first:
name: _TintColor
second: {r: 1, g: 1, b: 1, a: 1}

View file

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: ee25fb26e9e357d48893fa69862a63d2
NativeFormatImporter:
userData:

View file

@ -0,0 +1,40 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: SwordSwingMat
m_Shader: {fileID: 200, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _DecalTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: 19bac775940f2024a80fd4f854a89757, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _InvFade
second: 1
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _TintColor
second: {r: 1, g: 1, b: 1, a: 1}

View file

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 75a9595d302878140b92c9b78b8d8a54
NativeFormatImporter:
userData:

View file

@ -0,0 +1,34 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: SwordSwingRoughMat
m_Shader: {fileID: 200, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: 0e3f7f3b6dce3a94a86111da4203b740, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _InvFade
second: 1
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _TintColor
second: {r: 1, g: 1, b: 1, a: 1}

View file

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: ba822564932e653439da54554926872f
NativeFormatImporter:
userData:

View file

@ -0,0 +1,37 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: TankShellTrail
m_Shader: {fileID: 4800000, guid: c105fca0e8365434ab3e97e8a6979893, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: 62418b70010db0749956023a9435a814, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: PixelSnap
second: 0
- first:
name: _InvFade
second: 1
m_Colors:
- first:
name: _Color
second: {r: 1, g: 0.8482759, b: 0, a: 1}
- first:
name: _TintColor
second: {r: 1, g: 1, b: 1, a: 1}

View file

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 74ac504b5aa2e7045830c0f69e8d297e
NativeFormatImporter:
userData:

View file

@ -0,0 +1,52 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: TankSmoke
m_Shader: {fileID: 203, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _BumpMap
second:
m_Texture: {fileID: 2800000, guid: 984639d35625032479433f0f906a8bda, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: 98450d1e53061f840886062fc42513fa, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _Cutoff
second: 0.4464286
- first:
name: _InvFade
second: 1
- first:
name: _Shininess
second: 0.70927906
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _EmisColor
second: {r: 0.2, g: 0.2, b: 0.2, a: 0}
- first:
name: _SpecColor
second: {r: 0.1397059, g: 0.1397059, b: 0.1397059, a: 1}
- first:
name: _TintColor
second: {r: 0.69411767, g: 0.69411767, b: 0.69411767, a: 0.11764706}

View file

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 31435463954d86b4d837cc81741fbf2d
NativeFormatImporter:
userData:

View file

@ -0,0 +1,28 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UsedShell
m_Shader: {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats: []
m_Colors:
- first:
name: _Color
second: {r: 0.33088237, g: 0.33088237, b: 0.33088237, a: 1}

View file

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: 28b26d01baf691f41ae86e9f14169cc5
NativeFormatImporter:
userData:

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 14d3150ca4de43f4b96ec7b2073cd409
folderAsset: yes
timeCreated: 1497081290
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: e0c6b2c9ac2b99d44a2fddaf4a1f2e1f
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,286 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace PigeonCoopToolkit.Utillities
{
public class CircularBuffer<T> : IList<T>, ICollection<T>,
IEnumerable<T>, IEnumerable
{
/// <summary>
/// Creates a new instance of a <see cref="RingBuffer&lt;T&gt;"/> with a
/// specified cache size.
/// </summary>
/// <param name="capacity">The maximal count of items to be stored within
/// the ring buffer.</param>
public CircularBuffer(int capacity)
{
// validate capacity
if (capacity <= 0)
throw new ArgumentException("Must be greater than zero", "capacity");
// set capacity and init the cache
Capacity = capacity;
_buffer = new T[capacity];
}
/// <summary>
/// the internal buffer
/// </summary>
T[] _buffer;
/// <summary>
/// The all-over position within the ring buffer. The position
/// increases continously by adding new items to the buffer. This
/// value is needed to calculate the current relative position within the
/// buffer.
/// </summary>
int _position;
/// <summary>
/// The current version of the buffer, this is required for a correct
/// exception handling while enumerating over the items of the buffer.
/// </summary>
long _version;
/// <summary>
/// Gets or sets an item for a specified position within the ring buffer.
/// </summary>
/// <param name="index">The position to get or set an item.</param>
/// <returns>The fond item at the specified position within the ring buffer.
/// </returns>
/// <exception cref="IndexOutOfRangeException"></exception>
public T this[int index] {
get {
// validate the index
if (index < 0 || index >= Count)
throw new IndexOutOfRangeException();
// calculate the relative position within the rolling base array
int index2 = (_position - Count + index) % Capacity;
return _buffer[index2];
}
set { Insert(index, value); }
}
/// <summary>
/// Gets the maximal count of items within the ring buffer.
/// </summary>
public int Capacity { get; private set; }
/// <summary>
/// Get the current count of items within the ring buffer.
/// </summary>
public int Count { get; private set; }
/// <summary>
/// Adds a new item to the buffer.
/// </summary>
/// <param name="item">The item to be added to the buffer.</param>
public void Add(T item) {
// add a new item to the current relative position within the
// buffer and increase the position
_buffer[_position++ % Capacity] = item;
// increase the count if capacity is not yet reached
if (Count < Capacity) Count++;
// buffer changed; next version
_version++;
}
/// <summary>
/// Clears the whole buffer and releases all referenced objects
/// currently stored within the buffer.
/// </summary>
public void Clear() {
for (int i = 0; i < Count; i++)
_buffer[i] = default(T);
_position = 0;
Count = 0;
_version++;
}
/// <summary>
/// Determines if a specified item is currently present within
/// the buffer.
/// </summary>
/// <param name="item">The item to search for within the current
/// buffer.</param>
/// <returns>True if the specified item is currently present within
/// the buffer; otherwise false.</returns>
public bool Contains(T item) {
int index = IndexOf(item);
return index != -1;
}
/// <summary>
/// Copies the current items within the buffer to a specified array.
/// </summary>
/// <param name="array">The target array to copy the items of
/// the buffer to.</param>
/// <param name="arrayIndex">The start position witihn the target
/// array to start copying.</param>
public void CopyTo(T[] array, int arrayIndex) {
for (int i = 0; i < Count; i++) {
array[i + arrayIndex] = _buffer[(_position - Count + i) % Capacity];
}
}
/// <summary>
/// Gets an enumerator over the current items within the buffer.
/// </summary>
/// <returns>An enumerator over the current items within the buffer.
/// </returns>
public IEnumerator<T> GetEnumerator() {
long version = _version;
for (int i = 0; i < Count; i++) {
if (version != _version)
throw new InvalidOperationException("Collection changed");
yield return this[i];
}
}
/// <summary>
/// Gets the position of a specied item within the ring buffer.
/// </summary>
/// <param name="item">The item to get the current position for.</param>
/// <returns>The zero based index of the found item within the
/// buffer. If the item was not present within the buffer, this
/// method returns -1.</returns>
public int IndexOf(T item) {
// loop over the current count of items
for (int i = 0; i < Count; i++) {
// get the item at the relative position within the internal array
T item2 = _buffer[(_position - Count + i) % Capacity];
// if both items are null, return true
if (null == item && null == item2)
return i;
// if equal return the position
if (item != null && item.Equals(item2))
return i;
}
// nothing found
return -1;
}
/// <summary>
/// Inserts an item at a specified position into the buffer.
/// </summary>
/// <param name="index">The position within the buffer to add
/// the new item.</param>
/// <param name="item">The new item to be added to the buffer.</param>
/// <exception cref="IndexOutOfRangeException"></exception>
/// <remarks>
/// If the specified index is equal to the current count of items
/// within the buffer, the specified item will be added.
///
/// <b>Warning</b>
/// Frequent usage of this method might become a bad idea if you are
/// working with a large buffer capacity. The insertion of an item
/// at a specified position within the buffer causes causes all present
/// items below the specified position to be moved one position.
/// </remarks>
public void Insert(int index, T item) {
// validate index
if (index < 0 || index > Count)
throw new IndexOutOfRangeException();
// add if index equals to count
if (index == Count) {
Add(item);
return;
}
// get the maximal count of items to be moved
int count = Math.Min(Count, Capacity - 1) - index;
// get the relative position of the new item within the buffer
int index2 = (_position - Count + index) % Capacity;
// move all items below the specified position
for (int i = index2 + count; i > index2; i--) {
int to = i % Capacity;
int from = (i - 1) % Capacity;
_buffer[to] = _buffer[from];
}
// set the new item
_buffer[index2] = item;
// adjust storage information
if (Count < Capacity) {
Count++;
_position++;
}
// buffer changed; next version
_version++;
}
/// <summary>
/// Removes a specified item from the current buffer.
/// </summary>
/// <param name="item">The item to be removed.</param>
/// <returns>True if the specified item was successfully removed
/// from the buffer; otherwise false.</returns>
/// <remarks>
/// <b>Warning</b>
/// Frequent usage of this method might become a bad idea if you are
/// working with a large buffer capacity. The removing of an item
/// requires a scan of the buffer to get the position of the specified
/// item. If the item was found, the deletion requires a move of all
/// items stored abouve the found position.
/// </remarks>
public bool Remove(T item) {
// find the position of the specified item
int index = IndexOf(item);
// item was not found; return false
if (index == -1)
return false;
// remove the item at the specified position
RemoveAt(index);
return true;
}
/// <summary>
/// Removes an item at a specified position within the buffer.
/// </summary>
/// <param name="index">The position of the item to be removed.</param>
/// <exception cref="IndexOutOfRangeException"></exception>
/// <remarks>
/// <b>Warning</b>
/// Frequent usage of this method might become a bad idea if you are
/// working with a large buffer capacity. The deletion requires a move
/// of all items stored abouve the found position.
/// </remarks>
public void RemoveAt(int index) {
// validate the index
if (index < 0 || index >= Count)
throw new IndexOutOfRangeException();
// move all items above the specified position one step
// closer to zeri
for (int i = index; i < Count - 1; i++) {
// get the next relative target position of the item
int to = (_position - Count + i) % Capacity;
// get the next relative source position of the item
int from = (_position - Count + i + 1) % Capacity;
// move the item
_buffer[to] = _buffer[from];
}
// get the relative position of the last item, which becomes empty
// after deletion and set the item as empty
int last = (_position - 1) % Capacity;
_buffer[last] = default(T);
// adjust storage information
_position--;
Count--;
// buffer changed; next version
_version++;
}
/// <summary>
/// Gets if the buffer is read-only. This method always returns false.
/// </summary>
bool ICollection<T>.IsReadOnly { get { return false; } }
/// <summary>
/// See generic implementation of <see cref="GetEnumerator"/>.
/// </summary>
/// <returns>See generic implementation of <see cref="GetEnumerator"/>.
/// </returns>
IEnumerator IEnumerable.GetEnumerator() {
return this.GetEnumerator();
}
}
}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 51a19be087405654c8b4b50c67fa9200
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 5bd6a89e61571ac4da1296f14bbb936e
folderAsset: yes
DefaultImporter:
userData:

View file

@ -0,0 +1,34 @@
using UnityEditor;
using UnityEngine;
namespace PigeonCoopToolkit.Utillities.Editor
{
[CustomPropertyDrawer(typeof(Range))]
public class RangePropertyDrawer : PropertyDrawer
{
public override void OnGUI(UnityEngine.Rect position, SerializedProperty property, UnityEngine.GUIContent label)
{
SerializedProperty Min = property.FindPropertyRelative("Min");
SerializedProperty Max = property.FindPropertyRelative("Max");
Vector2 newMinMax = Vector2.zero;
position.height = 16;
EditorGUI.LabelField(position, label);
position.y += 20;
position.width = position.width / 2;
newMinMax.x = EditorGUI.FloatField(position, "Min", Min.floatValue);
position.x += position.width;
newMinMax.y = EditorGUI.FloatField(position, "Max", Max.floatValue);
if (newMinMax.x > newMinMax.y)
newMinMax.x = newMinMax.y;
Min.floatValue = newMinMax.x;
Max.floatValue = newMinMax.y;
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return base.GetPropertyHeight(property, label) + 20;
}
}
}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1eefccc24adb7c54a990dc0f9e669651
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -0,0 +1,33 @@
using UnityEngine;
namespace PigeonCoopToolkit.Utillities
{
public static class GizmosExtra
{
public static void GizmosDrawCircle(Vector3 position, Vector3 up, float size, int divisions)
{
Vector3 offset = (Quaternion.Euler(90,0,0) * (up* size)) ;
for (int i = 0; i < divisions; i++)
{
Vector3 newOffset = Quaternion.AngleAxis(360f / divisions, up) * offset;
Gizmos.DrawLine(position + offset, position + newOffset);
offset = newOffset;
}
}
public static void GizmosDrawArrow(Vector3 from, Vector3 to, float arrowSize)
{
Gizmos.DrawLine(from, to);
Vector3 dir = to - from;
dir = dir.normalized*arrowSize;
Gizmos.DrawLine(to, to - Quaternion.Euler(0, 0, 45)*dir);
Gizmos.DrawLine(to, to - Quaternion.Euler(0, 0, -45)*dir);
}
}
}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ac8be081485ba1141bd28334fe9eabec
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -0,0 +1,15 @@
namespace PigeonCoopToolkit.Utillities
{
[System.Serializable]
public class Range
{
public float Min;
public float Max;
public bool WithinRange(float value)
{
return Min <= value && Max >= value;
}
}
}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: db4c92c149ebf004a83b3776345ca8d4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View file

@ -1852,6 +1852,27 @@
<Compile Include="Assets\SEGI\SEGICascaded.cs" />
<Compile Include="Assets\SEGI\SEGICascadedPreset.cs" />
<Compile Include="Assets\SEGI\SEGIPreset.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\Editor\PCTKEffectsIntroDialogue.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\Editor\SmokePlumeEditor.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\Editor\SmokeTrailEditor.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\Editor\TrailEditor.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\Editor\TrailEditor_Base.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\Editor\TrailPreviewUtillity.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\PCTrail.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\PCTrailPoint.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\PCTrailRendererData.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\SmokePlume.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\SmokeTrail.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\SmokeTrailPoint.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\SmoothTrail.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\Trail.cs" />
<Compile Include="Assets\TrailEffect\Effects\Trails\TrailRenderer_Base.cs" />
<Compile Include="Assets\TrailEffect\Generic\Editor\IntroDialogue.cs" />
<Compile Include="Assets\TrailEffect\Generic\VersionInformation.cs" />
<Compile Include="Assets\TrailEffect\Utillities\CircularBuffer.cs" />
<Compile Include="Assets\TrailEffect\Utillities\Editor\RangePropertyDrawer.cs" />
<Compile Include="Assets\TrailEffect\Utillities\GizmosExtra.cs" />
<Compile Include="Assets\TrailEffect\Utillities\Range.cs" />
</ItemGroup>
<ItemGroup>
<None Include=".gitattributes" />