1234567891011121314151617181920212223242526 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEditor;
- public class ToolTipsEditor : Editor
- {
- [MenuItem("GameObject/Chiva/ToolTips/给子级添加TooltipsElement", priority = 0)]
- public static void AddToolTipsForChild()
- {
- Transform obj = Selection.activeGameObject.transform;
- for (int i = 0; i < obj.childCount; i++)
- {
- Transform tempChild = obj.GetChild(i);
- ToolTipsElement tempElement = tempChild.GetComponent<ToolTipsElement>() == null
- ? tempChild.gameObject.AddComponent<ToolTipsElement>()
- : tempChild.GetComponent<ToolTipsElement>();
- tempElement.toolName = tempChild.gameObject.name;
- }
- foreach (var item in obj.GetComponentsInChildren<MeshRenderer>())
- {
- if (item.transform.GetComponent<MeshCollider>() == null)
- item.gameObject.AddComponent<MeshCollider>();
- }
- }
- }
|