diff --git a/Assets/TrailEffect/Effects.meta b/Assets/TrailEffect/Effects.meta new file mode 100644 index 0000000..282db63 --- /dev/null +++ b/Assets/TrailEffect/Effects.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 6a726ba0fdae4d440984f5fdb4733d17 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Effects/Trails.meta b/Assets/TrailEffect/Effects/Trails.meta new file mode 100644 index 0000000..b5b2a9f --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: f8269202cdc317242afb02d19b41b357 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Effects/Trails/Editor.meta b/Assets/TrailEffect/Effects/Trails/Editor.meta new file mode 100644 index 0000000..fde7a7e --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Editor.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 35bda278aee224f419e59e01d4a4ff06 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Effects/Trails/Editor/PCTKEffectsIntroDialogue.cs b/Assets/TrailEffect/Effects/Trails/Editor/PCTKEffectsIntroDialogue.cs new file mode 100644 index 0000000..08c9424 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Editor/PCTKEffectsIntroDialogue.cs @@ -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(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); + } + } + } + +} + \ No newline at end of file diff --git a/Assets/TrailEffect/Effects/Trails/Editor/PCTKEffectsIntroDialogue.cs.meta b/Assets/TrailEffect/Effects/Trails/Editor/PCTKEffectsIntroDialogue.cs.meta new file mode 100644 index 0000000..f479bd4 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Editor/PCTKEffectsIntroDialogue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 83aee9145022a53418a0c515cc492327 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/TrailEffect/Effects/Trails/Editor/SmokePlumeEditor.cs b/Assets/TrailEffect/Effects/Trails/Editor/SmokePlumeEditor.cs new file mode 100644 index 0000000..52e52ee --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Editor/SmokePlumeEditor.cs @@ -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")); + } + } +} diff --git a/Assets/TrailEffect/Effects/Trails/Editor/SmokePlumeEditor.cs.meta b/Assets/TrailEffect/Effects/Trails/Editor/SmokePlumeEditor.cs.meta new file mode 100644 index 0000000..7c4cee3 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Editor/SmokePlumeEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ddcb2ed96cba10e4da2cae8ff8533fda +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/TrailEffect/Effects/Trails/Editor/SmokeTrailEditor.cs b/Assets/TrailEffect/Effects/Trails/Editor/SmokeTrailEditor.cs new file mode 100644 index 0000000..574ba8a --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Editor/SmokeTrailEditor.cs @@ -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")); + } + } +} diff --git a/Assets/TrailEffect/Effects/Trails/Editor/SmokeTrailEditor.cs.meta b/Assets/TrailEffect/Effects/Trails/Editor/SmokeTrailEditor.cs.meta new file mode 100644 index 0000000..a823df9 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Editor/SmokeTrailEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bf32d2b00d1c88c4b91cf689b5f770c5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/TrailEffect/Effects/Trails/Editor/TrailEditor.cs b/Assets/TrailEffect/Effects/Trails/Editor/TrailEditor.cs new file mode 100644 index 0000000..713b128 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Editor/TrailEditor.cs @@ -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")); + } + } +} diff --git a/Assets/TrailEffect/Effects/Trails/Editor/TrailEditor.cs.meta b/Assets/TrailEffect/Effects/Trails/Editor/TrailEditor.cs.meta new file mode 100644 index 0000000..8cde7a7 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Editor/TrailEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dba587684cc69dc4097b307d0bacf81d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/TrailEffect/Effects/Trails/Editor/TrailEditor_Base.cs b/Assets/TrailEffect/Effects/Trails/Editor/TrailEditor_Base.cs new file mode 100644 index 0000000..29f4673 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Editor/TrailEditor_Base.cs @@ -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() + {} + } +} diff --git a/Assets/TrailEffect/Effects/Trails/Editor/TrailEditor_Base.cs.meta b/Assets/TrailEffect/Effects/Trails/Editor/TrailEditor_Base.cs.meta new file mode 100644 index 0000000..95f9b91 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Editor/TrailEditor_Base.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0ab5f16befc58ca4bbfb8159ae3ead06 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/TrailEffect/Effects/Trails/Editor/TrailPreviewUtillity.cs b/Assets/TrailEffect/Effects/Trails/Editor/TrailPreviewUtillity.cs new file mode 100644 index 0000000..d8ca78d --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Editor/TrailPreviewUtillity.cs @@ -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(); + } + + } +} + +*/ \ No newline at end of file diff --git a/Assets/TrailEffect/Effects/Trails/Editor/TrailPreviewUtillity.cs.meta b/Assets/TrailEffect/Effects/Trails/Editor/TrailPreviewUtillity.cs.meta new file mode 100644 index 0000000..6f9d52b --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Editor/TrailPreviewUtillity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 34af64ac36cf82046853c1e9e5421c3b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/TrailEffect/Effects/Trails/Icons.meta b/Assets/TrailEffect/Effects/Trails/Icons.meta new file mode 100644 index 0000000..b053e36 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Icons.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: e88319607f0d43843b735c35e8da7d61 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Effects/Trails/Icons/SmokPlumeIcon.png b/Assets/TrailEffect/Effects/Trails/Icons/SmokPlumeIcon.png new file mode 100644 index 0000000..a156426 Binary files /dev/null and b/Assets/TrailEffect/Effects/Trails/Icons/SmokPlumeIcon.png differ diff --git a/Assets/TrailEffect/Effects/Trails/Icons/SmokeTrailIcon.png b/Assets/TrailEffect/Effects/Trails/Icons/SmokeTrailIcon.png new file mode 100644 index 0000000..619241b Binary files /dev/null and b/Assets/TrailEffect/Effects/Trails/Icons/SmokeTrailIcon.png differ diff --git a/Assets/TrailEffect/Effects/Trails/Icons/TrailIcon.png b/Assets/TrailEffect/Effects/Trails/Icons/TrailIcon.png new file mode 100644 index 0000000..f372904 Binary files /dev/null and b/Assets/TrailEffect/Effects/Trails/Icons/TrailIcon.png differ diff --git a/Assets/TrailEffect/Effects/Trails/PCTrail.cs b/Assets/TrailEffect/Effects/Trails/PCTrail.cs new file mode 100644 index 0000000..ddab263 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/PCTrail.cs @@ -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 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(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; + } + } +} diff --git a/Assets/TrailEffect/Effects/Trails/PCTrail.cs.meta b/Assets/TrailEffect/Effects/Trails/PCTrail.cs.meta new file mode 100644 index 0000000..7875d73 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/PCTrail.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6bdb573c1d60b9b4c9c5813da7dd36b3 +timeCreated: 1510298205 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TrailEffect/Effects/Trails/PCTrailPoint.cs b/Assets/TrailEffect/Effects/Trails/PCTrailPoint.cs new file mode 100644 index 0000000..f551e28 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/PCTrailPoint.cs @@ -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; + } + } +} diff --git a/Assets/TrailEffect/Effects/Trails/PCTrailPoint.cs.meta b/Assets/TrailEffect/Effects/Trails/PCTrailPoint.cs.meta new file mode 100644 index 0000000..e80c01d --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/PCTrailPoint.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d1183b720c636c54187be6b54124b9d8 +timeCreated: 1510298399 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TrailEffect/Effects/Trails/PCTrailRendererData.cs b/Assets/TrailEffect/Effects/Trails/PCTrailRendererData.cs new file mode 100644 index 0000000..26df792 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/PCTrailRendererData.cs @@ -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; + } +} diff --git a/Assets/TrailEffect/Effects/Trails/PCTrailRendererData.cs.meta b/Assets/TrailEffect/Effects/Trails/PCTrailRendererData.cs.meta new file mode 100644 index 0000000..931dc15 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/PCTrailRendererData.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2df86c9fa942e934f8d1b47514ebeeca +timeCreated: 1510298132 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TrailEffect/Effects/Trails/Resources.meta b/Assets/TrailEffect/Effects/Trails/Resources.meta new file mode 100644 index 0000000..256089d --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Resources.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 6f284d34362cfbd4dac1f041e217159f +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Effects/Trails/Resources/PCTK.meta b/Assets/TrailEffect/Effects/Trails/Resources/PCTK.meta new file mode 100644 index 0000000..787e14e --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Resources/PCTK.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: cb26a4a5e9479484ea1e4015d6117887 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Effects/Trails/Resources/PCTK/Effects.meta b/Assets/TrailEffect/Effects/Trails/Resources/PCTK/Effects.meta new file mode 100644 index 0000000..0f440bd --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Resources/PCTK/Effects.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: f4c3d22dfd9259b47bd18e2fbb40a661 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Effects/Trails/Resources/PCTK/Effects/Trails.meta b/Assets/TrailEffect/Effects/Trails/Resources/PCTK/Effects/Trails.meta new file mode 100644 index 0000000..ddc0226 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Resources/PCTK/Effects/Trails.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 9c92f0fb3caf95948bab8c97c7c38a7d +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Effects/Trails/SmokePlume.cs b/Assets/TrailEffect/Effects/Trails/SmokePlume.cs new file mode 100644 index 0000000..17e2587 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/SmokePlume.cs @@ -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 enumerator = trail.Points.GetEnumerator(); + while (enumerator.MoveNext()) + { + PCTrailPoint current = enumerator.Current; + current.Position += this.ConstantForce * deltaTime; + } + } + + protected override int GetMaxNumberOfPoints() + { + return this.MaxNumberOfPoints; + } + } +} diff --git a/Assets/TrailEffect/Effects/Trails/SmokePlume.cs.meta b/Assets/TrailEffect/Effects/Trails/SmokePlume.cs.meta new file mode 100644 index 0000000..d395369 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/SmokePlume.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9150799c728c3564980a1475e0a0808c +timeCreated: 1510298265 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TrailEffect/Effects/Trails/SmokeTrail.cs b/Assets/TrailEffect/Effects/Trails/SmokeTrail.cs new file mode 100644 index 0000000..0819fd8 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/SmokeTrail.cs @@ -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; + } + } +} diff --git a/Assets/TrailEffect/Effects/Trails/SmokeTrail.cs.meta b/Assets/TrailEffect/Effects/Trails/SmokeTrail.cs.meta new file mode 100644 index 0000000..49e8180 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/SmokeTrail.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6e5843f68b0854409013b4b9196c5fd +timeCreated: 1510298456 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TrailEffect/Effects/Trails/SmokeTrailPoint.cs b/Assets/TrailEffect/Effects/Trails/SmokeTrailPoint.cs new file mode 100644 index 0000000..8adebed --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/SmokeTrailPoint.cs @@ -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; + } + } +} diff --git a/Assets/TrailEffect/Effects/Trails/SmokeTrailPoint.cs.meta b/Assets/TrailEffect/Effects/Trails/SmokeTrailPoint.cs.meta new file mode 100644 index 0000000..fd47624 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/SmokeTrailPoint.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2cd086e711bdc064f8bc07309eedeb68 +timeCreated: 1510298131 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TrailEffect/Effects/Trails/SmoothTrail.cs b/Assets/TrailEffect/Effects/Trails/SmoothTrail.cs new file mode 100644 index 0000000..58b850a --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/SmoothTrail.cs @@ -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 _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(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); + } + } +} diff --git a/Assets/TrailEffect/Effects/Trails/SmoothTrail.cs.meta b/Assets/TrailEffect/Effects/Trails/SmoothTrail.cs.meta new file mode 100644 index 0000000..1cd2898 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/SmoothTrail.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fd5b6425a33ee3749a6a773b54f07066 +timeCreated: 1510298520 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TrailEffect/Effects/Trails/Trail.cs b/Assets/TrailEffect/Effects/Trails/Trail.cs new file mode 100644 index 0000000..276cf33 --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Trail.cs @@ -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; + } + } +} diff --git a/Assets/TrailEffect/Effects/Trails/Trail.cs.meta b/Assets/TrailEffect/Effects/Trails/Trail.cs.meta new file mode 100644 index 0000000..fce64df --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/Trail.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3f6ff3d33c169d34ca9bc146f4ef62ce +timeCreated: 1510298149 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TrailEffect/Effects/Trails/TrailRenderer_Base.cs b/Assets/TrailEffect/Effects/Trails/TrailRenderer_Base.cs new file mode 100644 index 0000000..c07be6d --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/TrailRenderer_Base.cs @@ -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 _fadingTrails; + + protected Transform _t; + + private static Dictionary> _matToTrailList; + + private static List _toClean; + + private static bool _hasRenderer; + + private static int GlobalTrailRendererCount; + + protected virtual void Awake() + { + GlobalTrailRendererCount++; + if (GlobalTrailRendererCount == 1) + { + _matToTrailList = new Dictionary>(); + _toClean = new List(); + } + _fadingTrails = new List(); + _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> 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()); + } + 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 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 circularBuffer = new CircularBuffer(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; + } + } +} diff --git a/Assets/TrailEffect/Effects/Trails/TrailRenderer_Base.cs.meta b/Assets/TrailEffect/Effects/Trails/TrailRenderer_Base.cs.meta new file mode 100644 index 0000000..6389dfd --- /dev/null +++ b/Assets/TrailEffect/Effects/Trails/TrailRenderer_Base.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 21f59b203fc36464997343d7fbb43d8f +timeCreated: 1510298121 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TrailEffect/Generic.meta b/Assets/TrailEffect/Generic.meta new file mode 100644 index 0000000..476b0ed --- /dev/null +++ b/Assets/TrailEffect/Generic.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 0a9b95943ee423546af04cdf2ca77dcb +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Generic/Editor.meta b/Assets/TrailEffect/Generic/Editor.meta new file mode 100644 index 0000000..cbaaede --- /dev/null +++ b/Assets/TrailEffect/Generic/Editor.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 4bb7bc1d04cd01a44b699141de29a4f4 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Generic/Editor/IntroDialogue.cs b/Assets/TrailEffect/Generic/Editor/IntroDialogue.cs new file mode 100644 index 0000000..36d94eb --- /dev/null +++ b/Assets/TrailEffect/Generic/Editor/IntroDialogue.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/Assets/TrailEffect/Generic/Editor/IntroDialogue.cs.meta b/Assets/TrailEffect/Generic/Editor/IntroDialogue.cs.meta new file mode 100644 index 0000000..8a04d59 --- /dev/null +++ b/Assets/TrailEffect/Generic/Editor/IntroDialogue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 026003e24f7b7ce43b28fc3c8a4a40bf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/TrailEffect/Generic/Resources.meta b/Assets/TrailEffect/Generic/Resources.meta new file mode 100644 index 0000000..458f583 --- /dev/null +++ b/Assets/TrailEffect/Generic/Resources.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: f96a53c06e3e24b4cae13070f3b8a5cd +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Generic/Resources/PCTK.meta b/Assets/TrailEffect/Generic/Resources/PCTK.meta new file mode 100644 index 0000000..208e617 --- /dev/null +++ b/Assets/TrailEffect/Generic/Resources/PCTK.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: ca4b996a254788e47a48279672b9f8fc +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Generic/Resources/PCTK/Generic.meta b/Assets/TrailEffect/Generic/Resources/PCTK/Generic.meta new file mode 100644 index 0000000..43dc26c --- /dev/null +++ b/Assets/TrailEffect/Generic/Resources/PCTK/Generic.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: c3eef40730cf0864d97e8e04a0ee6f8e +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Generic/VersionInformation.cs b/Assets/TrailEffect/Generic/VersionInformation.cs new file mode 100644 index 0000000..96d2f9c --- /dev/null +++ b/Assets/TrailEffect/Generic/VersionInformation.cs @@ -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; + } + } + + } +} diff --git a/Assets/TrailEffect/Generic/VersionInformation.cs.meta b/Assets/TrailEffect/Generic/VersionInformation.cs.meta new file mode 100644 index 0000000..c5b4e1a --- /dev/null +++ b/Assets/TrailEffect/Generic/VersionInformation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1d58a7e753bea0e4c84779d092563363 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/TrailEffect/Materials.meta b/Assets/TrailEffect/Materials.meta new file mode 100644 index 0000000..8f0a3ec --- /dev/null +++ b/Assets/TrailEffect/Materials.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ed403bda32d6d8b4abc0e3a2de4b8fa1 +folderAsset: yes +timeCreated: 1497081290 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TrailEffect/Materials/Arrow.mat b/Assets/TrailEffect/Materials/Arrow.mat new file mode 100644 index 0000000..b5ebb44 --- /dev/null +++ b/Assets/TrailEffect/Materials/Arrow.mat @@ -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} diff --git a/Assets/TrailEffect/Materials/Arrow.mat.meta b/Assets/TrailEffect/Materials/Arrow.mat.meta new file mode 100644 index 0000000..ee7ab98 --- /dev/null +++ b/Assets/TrailEffect/Materials/Arrow.mat.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: bf90f05c17802054f98f9b5f331d8953 +NativeFormatImporter: + userData: diff --git a/Assets/TrailEffect/Materials/BarrelSmoke.mat b/Assets/TrailEffect/Materials/BarrelSmoke.mat new file mode 100644 index 0000000..4641b35 --- /dev/null +++ b/Assets/TrailEffect/Materials/BarrelSmoke.mat @@ -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} diff --git a/Assets/TrailEffect/Materials/BarrelSmoke.mat.meta b/Assets/TrailEffect/Materials/BarrelSmoke.mat.meta new file mode 100644 index 0000000..df64962 --- /dev/null +++ b/Assets/TrailEffect/Materials/BarrelSmoke.mat.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 2c45238b0e8e5b443a693d7c92c89d3e +NativeFormatImporter: + userData: diff --git a/Assets/TrailEffect/Materials/FlameSwordTrail.mat b/Assets/TrailEffect/Materials/FlameSwordTrail.mat new file mode 100644 index 0000000..db50afd --- /dev/null +++ b/Assets/TrailEffect/Materials/FlameSwordTrail.mat @@ -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} diff --git a/Assets/TrailEffect/Materials/FlameSwordTrail.mat.meta b/Assets/TrailEffect/Materials/FlameSwordTrail.mat.meta new file mode 100644 index 0000000..193b9a5 --- /dev/null +++ b/Assets/TrailEffect/Materials/FlameSwordTrail.mat.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: a6c0d0c41df93a243b0e594e935d9a86 +NativeFormatImporter: + userData: diff --git a/Assets/TrailEffect/Materials/LowPolyTankTextureTreadDecal.mat b/Assets/TrailEffect/Materials/LowPolyTankTextureTreadDecal.mat new file mode 100644 index 0000000..ada4e75 --- /dev/null +++ b/Assets/TrailEffect/Materials/LowPolyTankTextureTreadDecal.mat @@ -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} diff --git a/Assets/TrailEffect/Materials/LowPolyTankTextureTreadDecal.mat.meta b/Assets/TrailEffect/Materials/LowPolyTankTextureTreadDecal.mat.meta new file mode 100644 index 0000000..4e8c6d0 --- /dev/null +++ b/Assets/TrailEffect/Materials/LowPolyTankTextureTreadDecal.mat.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 0e0449aa4e0e216479ba4ebbe28e8288 +NativeFormatImporter: + userData: diff --git a/Assets/TrailEffect/Materials/MuzzleFlash.mat b/Assets/TrailEffect/Materials/MuzzleFlash.mat new file mode 100644 index 0000000..f94daef --- /dev/null +++ b/Assets/TrailEffect/Materials/MuzzleFlash.mat @@ -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} diff --git a/Assets/TrailEffect/Materials/MuzzleFlash.mat.meta b/Assets/TrailEffect/Materials/MuzzleFlash.mat.meta new file mode 100644 index 0000000..6030f44 --- /dev/null +++ b/Assets/TrailEffect/Materials/MuzzleFlash.mat.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 43839268c81ec7340b2eb815c164e0dd +NativeFormatImporter: + userData: diff --git a/Assets/TrailEffect/Materials/SelectionTrail.mat b/Assets/TrailEffect/Materials/SelectionTrail.mat new file mode 100644 index 0000000..d4b1e26 --- /dev/null +++ b/Assets/TrailEffect/Materials/SelectionTrail.mat @@ -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} diff --git a/Assets/TrailEffect/Materials/SelectionTrail.mat.meta b/Assets/TrailEffect/Materials/SelectionTrail.mat.meta new file mode 100644 index 0000000..5058e81 --- /dev/null +++ b/Assets/TrailEffect/Materials/SelectionTrail.mat.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: ee25fb26e9e357d48893fa69862a63d2 +NativeFormatImporter: + userData: diff --git a/Assets/TrailEffect/Materials/SwordSwingMat.mat b/Assets/TrailEffect/Materials/SwordSwingMat.mat new file mode 100644 index 0000000..911de14 --- /dev/null +++ b/Assets/TrailEffect/Materials/SwordSwingMat.mat @@ -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} diff --git a/Assets/TrailEffect/Materials/SwordSwingMat.mat.meta b/Assets/TrailEffect/Materials/SwordSwingMat.mat.meta new file mode 100644 index 0000000..7ad1493 --- /dev/null +++ b/Assets/TrailEffect/Materials/SwordSwingMat.mat.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 75a9595d302878140b92c9b78b8d8a54 +NativeFormatImporter: + userData: diff --git a/Assets/TrailEffect/Materials/SwordSwingRoughMat.mat b/Assets/TrailEffect/Materials/SwordSwingRoughMat.mat new file mode 100644 index 0000000..3acf9f9 --- /dev/null +++ b/Assets/TrailEffect/Materials/SwordSwingRoughMat.mat @@ -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} diff --git a/Assets/TrailEffect/Materials/SwordSwingRoughMat.mat.meta b/Assets/TrailEffect/Materials/SwordSwingRoughMat.mat.meta new file mode 100644 index 0000000..deeb190 --- /dev/null +++ b/Assets/TrailEffect/Materials/SwordSwingRoughMat.mat.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: ba822564932e653439da54554926872f +NativeFormatImporter: + userData: diff --git a/Assets/TrailEffect/Materials/TankShellTrail.mat b/Assets/TrailEffect/Materials/TankShellTrail.mat new file mode 100644 index 0000000..55a1441 --- /dev/null +++ b/Assets/TrailEffect/Materials/TankShellTrail.mat @@ -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} diff --git a/Assets/TrailEffect/Materials/TankShellTrail.mat.meta b/Assets/TrailEffect/Materials/TankShellTrail.mat.meta new file mode 100644 index 0000000..eacdd63 --- /dev/null +++ b/Assets/TrailEffect/Materials/TankShellTrail.mat.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 74ac504b5aa2e7045830c0f69e8d297e +NativeFormatImporter: + userData: diff --git a/Assets/TrailEffect/Materials/TankSmoke.mat b/Assets/TrailEffect/Materials/TankSmoke.mat new file mode 100644 index 0000000..83afe45 --- /dev/null +++ b/Assets/TrailEffect/Materials/TankSmoke.mat @@ -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} diff --git a/Assets/TrailEffect/Materials/TankSmoke.mat.meta b/Assets/TrailEffect/Materials/TankSmoke.mat.meta new file mode 100644 index 0000000..8eeea9a --- /dev/null +++ b/Assets/TrailEffect/Materials/TankSmoke.mat.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 31435463954d86b4d837cc81741fbf2d +NativeFormatImporter: + userData: diff --git a/Assets/TrailEffect/Materials/UsedShell.mat b/Assets/TrailEffect/Materials/UsedShell.mat new file mode 100644 index 0000000..8c107aa --- /dev/null +++ b/Assets/TrailEffect/Materials/UsedShell.mat @@ -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} diff --git a/Assets/TrailEffect/Materials/UsedShell.mat.meta b/Assets/TrailEffect/Materials/UsedShell.mat.meta new file mode 100644 index 0000000..2ff92a0 --- /dev/null +++ b/Assets/TrailEffect/Materials/UsedShell.mat.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 28b26d01baf691f41ae86e9f14169cc5 +NativeFormatImporter: + userData: diff --git a/Assets/TrailEffect/Textures.meta b/Assets/TrailEffect/Textures.meta new file mode 100644 index 0000000..7be4867 --- /dev/null +++ b/Assets/TrailEffect/Textures.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 14d3150ca4de43f4b96ec7b2073cd409 +folderAsset: yes +timeCreated: 1497081290 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TrailEffect/Textures/Arrow 1.png b/Assets/TrailEffect/Textures/Arrow 1.png new file mode 100644 index 0000000..e5b055b Binary files /dev/null and b/Assets/TrailEffect/Textures/Arrow 1.png differ diff --git a/Assets/TrailEffect/Textures/Arrow.png b/Assets/TrailEffect/Textures/Arrow.png new file mode 100644 index 0000000..7443856 Binary files /dev/null and b/Assets/TrailEffect/Textures/Arrow.png differ diff --git a/Assets/TrailEffect/Textures/SmokePlume 2.png b/Assets/TrailEffect/Textures/SmokePlume 2.png new file mode 100644 index 0000000..24d41c7 Binary files /dev/null and b/Assets/TrailEffect/Textures/SmokePlume 2.png differ diff --git a/Assets/TrailEffect/Textures/SmokePlume.png b/Assets/TrailEffect/Textures/SmokePlume.png new file mode 100644 index 0000000..8edaaa5 Binary files /dev/null and b/Assets/TrailEffect/Textures/SmokePlume.png differ diff --git a/Assets/TrailEffect/Textures/swingFX.png b/Assets/TrailEffect/Textures/swingFX.png new file mode 100644 index 0000000..41f6678 Binary files /dev/null and b/Assets/TrailEffect/Textures/swingFX.png differ diff --git a/Assets/TrailEffect/Textures/swingFXRough.png b/Assets/TrailEffect/Textures/swingFXRough.png new file mode 100644 index 0000000..fee9145 Binary files /dev/null and b/Assets/TrailEffect/Textures/swingFXRough.png differ diff --git a/Assets/TrailEffect/Utillities.meta b/Assets/TrailEffect/Utillities.meta new file mode 100644 index 0000000..8929b5b --- /dev/null +++ b/Assets/TrailEffect/Utillities.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: e0c6b2c9ac2b99d44a2fddaf4a1f2e1f +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Utillities/CircularBuffer.cs b/Assets/TrailEffect/Utillities/CircularBuffer.cs new file mode 100644 index 0000000..923dbe9 --- /dev/null +++ b/Assets/TrailEffect/Utillities/CircularBuffer.cs @@ -0,0 +1,286 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace PigeonCoopToolkit.Utillities +{ + public class CircularBuffer : IList, ICollection, + IEnumerable, IEnumerable + { + /// + /// Creates a new instance of a with a + /// specified cache size. + /// + /// The maximal count of items to be stored within + /// the ring buffer. + 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]; + } + + /// + /// the internal buffer + /// + T[] _buffer; + /// + /// 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. + /// + int _position; + /// + /// The current version of the buffer, this is required for a correct + /// exception handling while enumerating over the items of the buffer. + /// + long _version; + + /// + /// Gets or sets an item for a specified position within the ring buffer. + /// + /// The position to get or set an item. + /// The fond item at the specified position within the ring buffer. + /// + /// + 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); } + } + + /// + /// Gets the maximal count of items within the ring buffer. + /// + public int Capacity { get; private set; } + /// + /// Get the current count of items within the ring buffer. + /// + public int Count { get; private set; } + + /// + /// Adds a new item to the buffer. + /// + /// The item to be added to the buffer. + 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++; + } + + /// + /// Clears the whole buffer and releases all referenced objects + /// currently stored within the buffer. + /// + public void Clear() { + for (int i = 0; i < Count; i++) + _buffer[i] = default(T); + _position = 0; + Count = 0; + _version++; + } + + /// + /// Determines if a specified item is currently present within + /// the buffer. + /// + /// The item to search for within the current + /// buffer. + /// True if the specified item is currently present within + /// the buffer; otherwise false. + public bool Contains(T item) { + int index = IndexOf(item); + return index != -1; + } + + /// + /// Copies the current items within the buffer to a specified array. + /// + /// The target array to copy the items of + /// the buffer to. + /// The start position witihn the target + /// array to start copying. + public void CopyTo(T[] array, int arrayIndex) { + for (int i = 0; i < Count; i++) { + array[i + arrayIndex] = _buffer[(_position - Count + i) % Capacity]; + } + } + + /// + /// Gets an enumerator over the current items within the buffer. + /// + /// An enumerator over the current items within the buffer. + /// + public IEnumerator GetEnumerator() { + long version = _version; + for (int i = 0; i < Count; i++) { + if (version != _version) + throw new InvalidOperationException("Collection changed"); + yield return this[i]; + } + } + + /// + /// Gets the position of a specied item within the ring buffer. + /// + /// The item to get the current position for. + /// The zero based index of the found item within the + /// buffer. If the item was not present within the buffer, this + /// method returns -1. + 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; + } + + /// + /// Inserts an item at a specified position into the buffer. + /// + /// The position within the buffer to add + /// the new item. + /// The new item to be added to the buffer. + /// + /// + /// If the specified index is equal to the current count of items + /// within the buffer, the specified item will be added. + /// + /// Warning + /// 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. + /// + 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++; + } + + /// + /// Removes a specified item from the current buffer. + /// + /// The item to be removed. + /// True if the specified item was successfully removed + /// from the buffer; otherwise false. + /// + /// Warning + /// 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. + /// + 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; + } + + /// + /// Removes an item at a specified position within the buffer. + /// + /// The position of the item to be removed. + /// + /// + /// Warning + /// 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. + /// + 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++; + } + + /// + /// Gets if the buffer is read-only. This method always returns false. + /// + bool ICollection.IsReadOnly { get { return false; } } + + /// + /// See generic implementation of . + /// + /// See generic implementation of . + /// + IEnumerator IEnumerable.GetEnumerator() { + return this.GetEnumerator(); + } + } +} diff --git a/Assets/TrailEffect/Utillities/CircularBuffer.cs.meta b/Assets/TrailEffect/Utillities/CircularBuffer.cs.meta new file mode 100644 index 0000000..eb81254 --- /dev/null +++ b/Assets/TrailEffect/Utillities/CircularBuffer.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 51a19be087405654c8b4b50c67fa9200 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/TrailEffect/Utillities/Editor.meta b/Assets/TrailEffect/Utillities/Editor.meta new file mode 100644 index 0000000..3bafe1c --- /dev/null +++ b/Assets/TrailEffect/Utillities/Editor.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 5bd6a89e61571ac4da1296f14bbb936e +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/TrailEffect/Utillities/Editor/RangePropertyDrawer.cs b/Assets/TrailEffect/Utillities/Editor/RangePropertyDrawer.cs new file mode 100644 index 0000000..38db991 --- /dev/null +++ b/Assets/TrailEffect/Utillities/Editor/RangePropertyDrawer.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/Assets/TrailEffect/Utillities/Editor/RangePropertyDrawer.cs.meta b/Assets/TrailEffect/Utillities/Editor/RangePropertyDrawer.cs.meta new file mode 100644 index 0000000..5769b0e --- /dev/null +++ b/Assets/TrailEffect/Utillities/Editor/RangePropertyDrawer.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1eefccc24adb7c54a990dc0f9e669651 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/TrailEffect/Utillities/GizmosExtra.cs b/Assets/TrailEffect/Utillities/GizmosExtra.cs new file mode 100644 index 0000000..05fa3c4 --- /dev/null +++ b/Assets/TrailEffect/Utillities/GizmosExtra.cs @@ -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); + + } + } +} diff --git a/Assets/TrailEffect/Utillities/GizmosExtra.cs.meta b/Assets/TrailEffect/Utillities/GizmosExtra.cs.meta new file mode 100644 index 0000000..dd47c41 --- /dev/null +++ b/Assets/TrailEffect/Utillities/GizmosExtra.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ac8be081485ba1141bd28334fe9eabec +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/TrailEffect/Utillities/Range.cs b/Assets/TrailEffect/Utillities/Range.cs new file mode 100644 index 0000000..99a8e7a --- /dev/null +++ b/Assets/TrailEffect/Utillities/Range.cs @@ -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; + } + } + +} diff --git a/Assets/TrailEffect/Utillities/Range.cs.meta b/Assets/TrailEffect/Utillities/Range.cs.meta new file mode 100644 index 0000000..991f43d --- /dev/null +++ b/Assets/TrailEffect/Utillities/Range.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: db4c92c149ebf004a83b3776345ca8d4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/fie.csproj b/fie.csproj index 1d25091..d124c01 100644 --- a/fie.csproj +++ b/fie.csproj @@ -1852,6 +1852,27 @@ + + + + + + + + + + + + + + + + + + + + +