Tanoda
pb_GUIStyleApplier.cs
Go to the documentation of this file.
1using UnityEngine;
2using UnityEngine.UI;
4using System.Collections;
5
6namespace GILES.Interface
7{
11 public class pb_GUIStyleApplier : MonoBehaviour
12 {
13 public bool ignoreStyle;
15
16 void Awake()
17 {
18 if(!ignoreStyle)
19 ApplyStyle();
20 }
21
22 public void ApplyStyle()
23 {
24 if(style == null || ignoreStyle)
25 return;
26
27 ApplyRecursive(gameObject);
28 }
29
30 private void ApplyRecursive(GameObject go)
31 {
32 foreach(Graphic graphic in go.GetComponents<Graphic>())
33 style.Apply(graphic);
34
35 foreach(Selectable selectable in go.GetComponents<Selectable>())
36 style.Apply(selectable);
37
38 foreach(Transform t in go.transform)
39 {
40 if(t.gameObject.GetComponent<pb_GUIStyleApplier>() != null)
41 continue;
42
43 ApplyRecursive(t.gameObject);
44 }
45 }
46 }
47}
virtual void Apply(Graphic element)
Definition: pb_GUIStyle.cs:78