-
Notifications
You must be signed in to change notification settings - Fork 2
/
Collection.cs
48 lines (37 loc) · 1.18 KB
/
Collection.cs
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System.Collections.Generic;
using UnityEngine;
namespace Ardenfall
{
[ExecuteInEditMode]
public class Collection : MonoBehaviour
{
//Randomize Collection
public virtual void Randomize() { }
public virtual void StepRotation(int step) { }
//Step Collection by step amount - negative means backwards
public virtual void Step(int step) { }
public virtual void Select(int index) { }
//Run when prefab is dropped into a scene
public virtual void OnAddToScene() { }
public virtual void UpdateCollection() { }
//Returns all direct Collection children
public List<Collection> GetChildren()
{
List<Collection> children = new List<Collection>();
for (int i =0;i<transform.childCount;i++)
{
Collection c = transform.GetChild(i).gameObject.GetComponent<Collection>();
if (c != null)
children.Add(c);
}
return children;
}
#if UNITY_EDITOR
private void Awake()
{
if(!Application.isPlaying)
UpdateCollection();
}
#endif
}
}