今天使用HUDText的时候,发现须要如今场景里创建一个UI2dRoot;不然位置不对
或许应该创建一个prefab这样每一个场景都加入一个就可以。
- using UnityEngine;
- using UnityEditor;
- public class FixStupidEditorBehavior : MonoBehaviour {
- [MenuItem("GameObject/Create Empty Parent #&e")]
- static void createEmptyParent() {
- GameObject go = new GameObject("GameObject");
- if(Selection.q=activeTransform">activeTransform != null)
- {
- go.transform.q=parent">parent = Selection.q=activeTransform">activeTransform.q=parent">parent;
- go.transform.Translate(Selection.q=activeTransform">activeTransform.position);
- Selection.activeTransform.parent = go.transform;
- }
- }
- [MenuItem("GameObject/Create Empty Duplicate #&d")]
- static void createEmptyDuplicate() {
- q=GameObject">GameObject go = new q=GameObject">GameObject("GameObject");
- if(q=Selection">Selection.q=activeTransform">activeTransform != null)
- {
- go.transform.parent = Selection.activeTransform.parent;
- go.transform.Translate(Selection.activeTransform.position);
- }
- }
- [MenuItem("GameObject/Create Empty Child #&c")]
- static void createEmptyChild() {
- GameObject go = new GameObject("GameObject");
- if(Selection.activeTransform != null)
- {
- go.transform.parent = Selection.q=activeTransform">activeTransform;
- go.transform.Translate(Selection.activeTransform.position);
- }
- }
- }
载入场景注意:异步载入场景的时候,NGUI是无法正常绘制的,须要用原生的OnGUI
时间: 2024-10-12 03:33:45