Skip to content
This repository was archived by the owner on Mar 24, 2022. It is now read-only.

Commit c9637cb

Browse files
committed
Added license headers
1 parent 7c09913 commit c9637cb

File tree

13 files changed

+364
-107
lines changed

13 files changed

+364
-107
lines changed

Assets/ScreenSpace/FizzleFade/Scenes/Fizzlefade.unity

+35
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@ GameObject:
563563
m_Component:
564564
- component: {fileID: 2145028102}
565565
- component: {fileID: 2145028103}
566+
- component: {fileID: 2145028105}
567+
- component: {fileID: 2145028104}
566568
m_Layer: 5
567569
m_Name: Container
568570
m_TagString: Untagged
@@ -600,3 +602,36 @@ MonoBehaviour:
600602
m_Name:
601603
m_EditorClassIdentifier:
602604
Image: {fileID: 1482613087504472, guid: d247adca757ed67458f5c0f402c93af0, type: 2}
605+
--- !u!114 &2145028104
606+
MonoBehaviour:
607+
m_ObjectHideFlags: 0
608+
m_PrefabParentObject: {fileID: 0}
609+
m_PrefabInternal: {fileID: 0}
610+
m_GameObject: {fileID: 2145028101}
611+
m_Enabled: 1
612+
m_EditorHideFlags: 0
613+
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
614+
m_Name:
615+
m_EditorClassIdentifier:
616+
m_Material: {fileID: 0}
617+
m_Color: {r: 1, g: 1, b: 1, a: 1}
618+
m_RaycastTarget: 1
619+
m_OnCullStateChanged:
620+
m_PersistentCalls:
621+
m_Calls: []
622+
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
623+
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
624+
m_Sprite: {fileID: 0}
625+
m_Type: 0
626+
m_PreserveAspect: 0
627+
m_FillCenter: 1
628+
m_FillMethod: 4
629+
m_FillAmount: 1
630+
m_FillClockwise: 1
631+
m_FillOrigin: 0
632+
--- !u!222 &2145028105
633+
CanvasRenderer:
634+
m_ObjectHideFlags: 0
635+
m_PrefabParentObject: {fileID: 0}
636+
m_PrefabInternal: {fileID: 0}
637+
m_GameObject: {fileID: 2145028101}

Assets/ScreenSpace/FizzleFade/Scripts/FizzleFade.cs

+53-98
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,86 @@
1-
using System;
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2017 Lewis Johnson
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
using System;
225
using System.Collections;
326
using System.Collections.Generic;
4-
using System.Security.Cryptography;
527
using UnityEngine;
628
using UnityEngine.UI;
729
using Random = System.Random;
830

9-
1031
namespace Assets.ScreenSpace.FizzleFade.Scripts {
1132

1233
public class FizzleFade : MonoBehaviour {
1334

14-
public GameObject Image;
35+
public Texture2D FizzleTexture2D;
36+
private bool _isFilled;
37+
1538
public void Start() {
1639
Fizzle(new Color(255, 0, 0, 255));
1740
}
1841

19-
public void StartFizzleFade(Color pixelColour) {
20-
21-
int width = (int)Math.Ceiling(GetComponent<RectTransform>().sizeDelta.x);
22-
int height = (int)Math.Ceiling(GetComponent<RectTransform>().sizeDelta.y);
23-
24-
var xAxisFilled = new List<int>();
25-
var yAxisFilled = new List<int>();
26-
var rand = new Random();
27-
28-
while (xAxisFilled.Count != width && yAxisFilled.Count != height) {
29-
30-
int x = rand.Next(0, width);
31-
if (xAxisFilled.Contains(x))
32-
continue;
33-
34-
int y = rand.Next(0, height);
35-
if (yAxisFilled.Contains(y))
36-
continue;
37-
38-
var img = Instantiate(Image, transform);
39-
img.GetComponent<Image>().color = pixelColour;
40-
img.GetComponent<RectTransform>().anchoredPosition = new Vector2(x, y);
41-
42-
xAxisFilled.Add(x);
43-
yAxisFilled.Add(y);
44-
45-
}
46-
}
47-
48-
public void StartFizzleFade2(Color pixelColour) {
49-
50-
int width = (int)Math.Ceiling(GetComponent<RectTransform>().sizeDelta.x) / 100;
51-
int height = (int)Math.Ceiling(GetComponent<RectTransform>().sizeDelta.y) / 100;
52-
53-
var xAxisFilled = new List<int>(width);
54-
var xrandom = new Random();
55-
xAxisFilled.Add(0);
56-
for (var i = 1; i < width; i++) {
57-
var swap = xrandom.Next(i - 1);
58-
xAxisFilled.Add(xAxisFilled[swap]);
59-
xAxisFilled[swap] = i;
60-
}
61-
62-
var yAxisFilled = new List<int>(height);
63-
var random = new Random();
64-
yAxisFilled.Add(0);
65-
for (var i = 1; i < height; i++) {
66-
var swap = random.Next(i - 1);
67-
yAxisFilled.Add(yAxisFilled[swap]);
68-
yAxisFilled[swap] = i;
69-
}
70-
71-
for (int x = 0; x < xAxisFilled.Count; x++) {
72-
for (int y = 0; y < yAxisFilled.Count; y++) {
73-
var img = Instantiate(Image, transform);
74-
img.GetComponent<Image>().color = pixelColour;
75-
img.GetComponent<RectTransform>().anchoredPosition = new Vector2(xAxisFilled[x], yAxisFilled[y]);
76-
}
77-
78-
}
79-
}
80-
8142
public void Fizzle(Color pixelColour) {
8243

8344
int width = (int)Math.Ceiling(GetComponent<RectTransform>().sizeDelta.x);
8445
int height = (int)Math.Ceiling(GetComponent<RectTransform>().sizeDelta.y);
46+
FizzleTexture2D = new Texture2D(height, width, TextureFormat.ARGB32, false);
8547

86-
var xList = new List<int>();
87-
var yList = new List<int>();
88-
for (int i = 0; i <= ((int)Math.Round(width / 10.0)) * 10; i += 10) {
89-
xList.Add(i);
90-
}
48+
var fillColorArray = FizzleTexture2D.GetPixels();
9149

92-
for (int i = 0; i <= ((int)Math.Round(height / 10.0)) * 10; i += 10) {
93-
yList.Add(i);
50+
for (var i = 0; i < fillColorArray.Length; ++i) {
51+
fillColorArray[i] = new Color(0, 0, 0, 0);
9452
}
9553

96-
Shuffle(xList);
97-
Shuffle(yList);
54+
FizzleTexture2D.SetPixels(fillColorArray);
55+
FizzleTexture2D.Apply();
56+
GetComponent<Image>().material.mainTexture = FizzleTexture2D;
9857

99-
for (int x = 0; x < xList.Count; x++) {
100-
for (int y = 0; y < yList.Count; y++) {
101-
var img = Instantiate(Image, transform);
102-
img.GetComponent<Image>().color = pixelColour;
103-
img.GetComponent<RectTransform>().anchoredPosition = new Vector2(xList[x], -yList[y]);
104-
img.SetActive(false);
105-
StartCoroutine(WaitAndPrint(img, (x * y) / 1000));
58+
for (int x = 0; x <= width; x++) {
59+
for (int y = 0; y <= height; y++) {
60+
//StartCoroutine(WaitAndPrint(x, y, pixelColour, 1));
61+
//FizzleTexture2D.SetPixel(x, y, pixelColour);
10662
}
107-
10863
}
10964

110-
//var child = new List<int>(transform.childCount);
111-
//var xrandom = new Random();
112-
//child.Add(0);
113-
//for (var i = 1; i < width; i++) {
114-
// var swap = xrandom.Next(i - 1);
115-
// child.Add(child[swap]);
116-
// child[swap] = i;
117-
//}
118-
119-
//for (int i = 0; i < child.Count; i++) {
120-
// StartCoroutine(WaitAndPrint(child[i], 1));
121-
//}
122-
65+
12366
}
12467

12568

126-
private IEnumerator WaitAndPrint(GameObject k, float waitTime) {
69+
private IEnumerator WaitAndPrint(int x, int y, Color pixelColour, float waitTime) {
70+
71+
FizzleTexture2D.SetPixel(x, y, pixelColour);
72+
12773
yield return new WaitForSeconds(waitTime);
128-
k.SetActive(true);
74+
75+
}
76+
77+
public void FixedUpdate()
78+
{
79+
if (!_isFilled)
80+
{
81+
FizzleTexture2D.Apply();
82+
}
83+
12984
}
13085

13186
public static void Shuffle<T>(IList<T> list) {

Assets/ScreenSpace/FizzleFade/Scripts/FizzleFade.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2017 Lewis Johnson
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
using System;
25+
using System.Collections;
26+
using System.Collections.Generic;
27+
using UnityEngine;
28+
using UnityEngine.UI;
29+
using Random = System.Random;
30+
31+
namespace Assets.ScreenSpace.FizzleFade.Scripts {
32+
33+
/// <summary>
34+
/// Please don't use this. It works but is a hot mess.
35+
/// </summary>
36+
public class TerribleFizzleFade : MonoBehaviour {
37+
38+
public GameObject Image;
39+
40+
public void Start() {
41+
Fizzle(new Color(255, 0, 0, 255));
42+
}
43+
44+
public void Fizzle(Color pixelColour) {
45+
46+
int width = (int)Math.Ceiling(GetComponent<RectTransform>().sizeDelta.x);
47+
int height = (int)Math.Ceiling(GetComponent<RectTransform>().sizeDelta.y);
48+
49+
var xList = new List<int>();
50+
var yList = new List<int>();
51+
for (int i = 0; i <= ((int)Math.Round(width / 10.0)) * 10; i += 10) {
52+
xList.Add(i);
53+
}
54+
55+
for (int i = 0; i <= ((int)Math.Round(height / 10.0)) * 10; i += 10) {
56+
yList.Add(i);
57+
}
58+
59+
Shuffle(xList);
60+
Shuffle(yList);
61+
62+
for (int x = 0; x < xList.Count; x++) {
63+
for (int y = 0; y < yList.Count; y++) {
64+
var img = Instantiate(Image, transform);
65+
img.GetComponent<Image>().color = pixelColour;
66+
img.GetComponent<RectTransform>().anchoredPosition = new Vector2(xList[x], -yList[y]);
67+
img.SetActive(false);
68+
StartCoroutine(WaitAndPrint(img, (x * y) / 1000));
69+
}
70+
71+
}
72+
}
73+
74+
75+
private IEnumerator WaitAndPrint(GameObject k, float waitTime) {
76+
yield return new WaitForSeconds(waitTime);
77+
k.SetActive(true);
78+
}
79+
80+
public static void Shuffle<T>(IList<T> list) {
81+
int n = list.Count;
82+
var rng = new Random();
83+
while (n > 1) {
84+
n--;
85+
int k = rng.Next(n + 1);
86+
T value = list[k];
87+
list[k] = list[n];
88+
list[n] = value;
89+
}
90+
}
91+
}
92+
93+
}
94+
95+

Assets/ScreenSpace/FizzleFade/Scripts/TerribleFizzleFade.cs.meta

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/ScreenSpace/Offset/Scripts/OffestUI.cs

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
SOFTWARE.
2323
*/
24-
2524
using UnityEngine;
2625

2726
namespace Assets.ScreenSpace.Offset.Scripts {

Assets/ScreenSpace/PercentageBased/Scripts/Container.cs

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1-
using UnityEngine;
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2017 Lewis Johnson
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
using UnityEngine;
225

326
namespace Assets.ScreenSpace.PercentageBased.Scripts {
427
[RequireComponent(typeof(RectTransform))]

0 commit comments

Comments
 (0)