private static void SetMouseRayUITarget() { GameObject[] objs = Selection.gameObjects; for (int i = 0; i < objs.Length; i++) { Graphic graphic = objs[i].GetComponent <Graphic>(); if (graphic) { graphic.raycastTarget = true; MouseRayUITarget rayUITarget = objs[i].GetComponent <MouseRayUITarget>(); if (!rayUITarget) { rayUITarget = Undo.AddComponent <MouseRayUITarget>(objs[i]); } rayUITarget.Name = objs[i].name; EditorUtility.SetDirty(objs[i]); } else { Log.Warning("对象 " + objs[i].name + " 没有Graphic组件,无法做为可捕获UI目标!"); } } }
private static void SetMouseRayUITarget() { GameObject[] objs = Selection.gameObjects; for (int i = 0; i < objs.Length; i++) { Graphic graphic = objs[i].GetComponent <Graphic>(); if (!graphic) { Log.Warning("对象 " + objs[i].name + " 没有Graphic组件,无法做为可捕获UI目标!"); continue; } graphic.raycastTarget = true; MouseRayUITarget rayUITarget = objs[i].GetComponent <MouseRayUITarget>(); if (!rayUITarget) { rayUITarget = objs[i].AddComponent <MouseRayUITarget>(); } rayUITarget.Name = objs[i].name; } }