Created
May 25, 2016 05:06
-
-
Save naojitaniguchi/a9b2ce6b8ac19bf9197e031159d44214 to your computer and use it in GitHub Desktop.
Set value to children under target node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| public class SetValueToChildren : MonoBehaviour { | |
| // Use this for initialization | |
| void Start () { | |
| } | |
| // Update is called once per frame | |
| void Update () { | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| using UnityEditor; | |
| [CustomEditor(typeof(SetValueToChildren))] | |
| public class SetValueToChildrenEditor : Editor | |
| { | |
| void setValueToMaterial( GameObject go) | |
| { | |
| Debug.Log(go.name); | |
| Renderer renderer = go.GetComponent<Renderer>(); | |
| if (renderer != null) | |
| { | |
| Debug.Log(go.name); | |
| renderer.sharedMaterial.SetFloat("valueName", 0.0f); | |
| } | |
| for (int i = 0; i < go.transform.childCount; i++) | |
| { | |
| Transform t = go.transform.GetChild(i); | |
| setLineWidthToMaterial(t.gameObject); | |
| } | |
| } | |
| public override void OnInspectorGUI() | |
| { | |
| if (GUILayout.Button("SetValue", GUILayout.Width(100f))) | |
| { | |
| SetValueToChildren myTarget = (SetValueToChildrenEditor)target; | |
| setValueToMaterial(myTarget.gameObject); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment