Skip to content

Commit b1ee7db

Browse files
committed
Trails will adjust to fill a predetermined width
1 parent 41bf20e commit b1ee7db

File tree

5 files changed

+72
-53
lines changed

5 files changed

+72
-53
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:1bbf505a0596de40b039d4cffd0448370cf7f78821d66e196eca98adcc4e5f3b
3-
size 31883
2+
oid sha256:0df15d5ec15d7f5dfa05bddcb00641eafd780067458f6d16d6b98ce2b2f81c29
3+
size 34013
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:c94528f3da0b847ff214ba541ca8bda7b965fc5acc7cac2fb2a84e4726921c18
3-
size 4016
2+
oid sha256:5ca90401930dece2e5709a4f95c51631518ef2feeb627c6cc63390d095721070
3+
size 4073

Assets/_Project/Scenes/tally-viz.unity

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,13 +1204,45 @@ PrefabInstance:
12041204
m_Modification:
12051205
m_TransformParent: {fileID: 0}
12061206
m_Modifications:
1207+
- target: {fileID: 716447069, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
1208+
propertyPath: positionMax
1209+
value: 1.5
1210+
objectReference: {fileID: 0}
1211+
- target: {fileID: 716447069, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
1212+
propertyPath: positionMin
1213+
value: -1.5
1214+
objectReference: {fileID: 0}
1215+
- target: {fileID: 2342437115836862262, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
1216+
propertyPath: positionMax
1217+
value: 1.5
1218+
objectReference: {fileID: 0}
1219+
- target: {fileID: 2342437115836862262, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
1220+
propertyPath: positionMin
1221+
value: -1.5
1222+
objectReference: {fileID: 0}
1223+
- target: {fileID: 4336535276446005831, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
1224+
propertyPath: positionMax
1225+
value: 1.5
1226+
objectReference: {fileID: 0}
1227+
- target: {fileID: 4336535276446005831, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
1228+
propertyPath: positionMin
1229+
value: -1.5
1230+
objectReference: {fileID: 0}
1231+
- target: {fileID: 6736848212216987026, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
1232+
propertyPath: positionMax
1233+
value: 1.5
1234+
objectReference: {fileID: 0}
1235+
- target: {fileID: 6736848212216987026, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
1236+
propertyPath: positionMin
1237+
value: -1.5
1238+
objectReference: {fileID: 0}
12071239
- target: {fileID: 7489948669748588920, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
12081240
propertyPath: m_LocalPosition.x
1209-
value: 0
1241+
value: -2.8600006
12101242
objectReference: {fileID: 0}
12111243
- target: {fileID: 7489948669748588920, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
12121244
propertyPath: m_LocalPosition.y
1213-
value: 0
1245+
value: -0.28
12141246
objectReference: {fileID: 0}
12151247
- target: {fileID: 7489948669748588920, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
12161248
propertyPath: m_LocalPosition.z
@@ -1248,6 +1280,14 @@ PrefabInstance:
12481280
propertyPath: m_LocalEulerAnglesHint.z
12491281
value: 0
12501282
objectReference: {fileID: 0}
1283+
- target: {fileID: 7676173138675737296, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
1284+
propertyPath: positionMax
1285+
value: 1.5
1286+
objectReference: {fileID: 0}
1287+
- target: {fileID: 7676173138675737296, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
1288+
propertyPath: positionMin
1289+
value: -1.5
1290+
objectReference: {fileID: 0}
12511291
- target: {fileID: 9008334923571228613, guid: ecec1fc7bdc6441a691ca908dfadc8b4, type: 3}
12521292
propertyPath: m_Name
12531293
value: PlayerPrefab

Assets/_Project/Scripts/Effects/TrailController.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ public class TrailController : MonoBehaviour {
99
public int trailIndex;
1010
public float trailWidth;
1111
float [] positionsByIndex = { -1f, -0.5f, 0, .5f, 1f };
12+
// Maximum position for overall trail edge
13+
public float positionMax = 1.5f;
14+
// Minimum position for overall trail edge
15+
public float positionMin = -1.5f;
16+
// Extra amount added to width to hide background
17+
public float widthExtra = 0.01f;
1218
public string trailColor;
1319
Color color;
1420

@@ -38,6 +44,26 @@ private void Awake ()
3844
trailIndex = transform.GetSiblingIndex ();
3945

4046

47+
// range between the positionMax and positionMin
48+
float positionRange = positionMax - positionMin;
49+
50+
// sets positionsByIndex array by number of trails
51+
positionsByIndex = new float[siblingCount];
52+
53+
// calculate range between each trail
54+
float trailsRange = positionRange / (siblingCount);
55+
56+
// place trails so the outer edges are touching positionMin and positionMax
57+
for (int i = 0; i < siblingCount; i++)
58+
{
59+
// starts with positionMin plus an offset that lets the trail edge touch it
60+
positionsByIndex[i] = positionMin + (trailsRange * (i + 0.5f)); // the 0.5 places it in the middle of the range, or something
61+
} // tbh I don't really know, I'm just glad it works
62+
63+
// set the trail width to the range plus a 'lil extra to cover the background
64+
trailWidth = trailsRange + widthExtra;
65+
66+
4167
// set offset based on index
4268
transform.localPosition = new Vector3 (0, positionsByIndex [trailIndex], 0);
4369

Packages/packages-lock.json

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,5 @@
11
{
22
"dependencies": {
3-
"com.unity.2d.animation": {
4-
"version": "4.2.6",
5-
"depth": 1,
6-
"source": "registry",
7-
"dependencies": {
8-
"com.unity.2d.common": "3.0.1",
9-
"com.unity.mathematics": "1.1.0",
10-
"com.unity.2d.sprite": "1.0.0",
11-
"com.unity.modules.animation": "1.0.0",
12-
"com.unity.modules.uielements": "1.0.0"
13-
},
14-
"url": "https://packages.unity.com"
15-
},
16-
"com.unity.2d.common": {
17-
"version": "3.0.1",
18-
"depth": 1,
19-
"source": "registry",
20-
"dependencies": {
21-
"com.unity.2d.sprite": "1.0.0",
22-
"com.unity.modules.uielements": "1.0.0"
23-
},
24-
"url": "https://packages.unity.com"
25-
},
26-
"com.unity.2d.psdimporter": {
27-
"version": "3.1.6",
28-
"depth": 0,
29-
"source": "registry",
30-
"dependencies": {
31-
"com.unity.2d.common": "3.0.1",
32-
"com.unity.2d.animation": "4.2.6",
33-
"com.unity.2d.sprite": "1.0.0"
34-
},
35-
"url": "https://packages.unity.com"
36-
},
37-
"com.unity.2d.sprite": {
38-
"version": "1.0.0",
39-
"depth": 1,
40-
"source": "builtin",
41-
"dependencies": {}
42-
},
433
"com.unity.collab-proxy": {
444
"version": "1.3.8",
455
"depth": 0,
@@ -77,13 +37,6 @@
7737
"dependencies": {},
7838
"url": "https://packages.unity.com"
7939
},
80-
"com.unity.mathematics": {
81-
"version": "1.1.0",
82-
"depth": 2,
83-
"source": "registry",
84-
"dependencies": {},
85-
"url": "https://packages.unity.com"
86-
},
8740
"com.unity.render-pipelines.core": {
8841
"version": "8.2.0",
8942
"depth": 1,

0 commit comments

Comments
 (0)