-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSpringBoneMarker.cs
44 lines (38 loc) · 1.15 KB
/
SpringBoneMarker.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpringBoneMarker : MonoBehaviour
{
public bool CheckHasChildren()
{
return transform.childCount != 0;
}
public void MarkChildren()
{
if (CheckHasChildren())
{
for (int i = 0; i < transform.childCount; i++)
{
GameObject child = transform.GetChild(i).gameObject;
if (child.transform.childCount != 0)
{
if (child.GetComponent<SpringBoneMarker>() == null)
{
child.AddComponent<SpringBoneMarker>();
child.GetComponent<SpringBoneMarker>().MarkChildren();
}
}
}
}
}
public UnityChan.SpringBone AddSpringBone()
{
UnityChan.SpringBone springBone = gameObject.AddComponent<UnityChan.SpringBone>();
springBone.child = gameObject.transform.GetChild(0);
return springBone;
}
public void UnmarkSelf()
{
DestroyImmediate(this);
}
}