-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathUtils.cs
64 lines (59 loc) · 1.6 KB
/
Utils.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
using System.IO;
namespace PowerInject
{
public class Utils
{
public static void print(String str)
{
return;
/*StreamWriter w = File.AppendText("c:/temp/test.txt");
w.Write(str + "\n");
w.Flush();
w.Close();*/
}
public static T getFirstComponentInParent<T>(GameObject g)
{
if (object.Equals(g, default(T)))
{
return default(T);
}
else
{
var c = g.GetComponent<T>();
if (c == null)
{
var parentTransform = g.transform.parent;
if (!object.Equals(parentTransform, default(T)))
{
return getFirstComponentInParent<T>(parentTransform.gameObject);
}
else
{
return default(T);
}
}
else
{
return c;
}
}
}
public static List<GameObject> getChildren(GameObject g)
{
var n = g.transform.childCount;
var children = new List<GameObject>();
for (int i = 0; i < n; i++)
{
children.Add(g.transform.GetChild(i).gameObject);
}
return children;
}
}
}