forked from JXPorter/OkitaUnity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.cs
More file actions
32 lines (30 loc) · 806 Bytes
/
Example.cs
File metadata and controls
32 lines (30 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour
{
void Start()
{
Toaster T = new Toaster();
T.ThingName = "Talkie";
print(T.ThingName);
Zombie Z = (Zombie)gameObject.AddComponent<Zombie>();
Z.ThingName = "Stubbs";
print(Z.ThingName);
}
// Update is called once per frame
public GameObject[] SortedByDistance;
void Update()
{
ArrayList ObjectList = new ArrayList();
GameObject[] Objects = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[];
foreach (GameObject go in Objects)
{
ObjectList.Add(go);
}
DistanceComparer dComparer = new DistanceComparer();
dComparer.Target = this.gameObject;
ObjectList.Sort(dComparer);
SortedByDistance = new GameObject[ObjectList.Count];
ObjectList.CopyTo(SortedByDistance);
}
}