protected Transform GetParent() { PanelGroup uigroup = null; if (serializedObject.targetObject is PanelGroup) { uigroup = serializedObject.targetObject as PanelGroup; } else { uigroup = Object.FindObjectOfType <PanelGroup>(); } if (uigroup != null) { return(uigroup.transform); } #if AssetBundleTools RuntimePanelGroup runtimeGroup = Object.FindObjectOfType <RuntimePanelGroup>(); if (runtimeGroup != null) { return(runtimeGroup.transform); } #endif return(null); }
protected Transform GetParent(GameObject prefab) { PanelGroup uigroup = null; if (serializedObject.targetObject is PanelGroup) { uigroup = serializedObject.targetObject as PanelGroup; } else { uigroup = Object.FindObjectOfType <PanelGroup>(); } if (uigroup != null) { return(uigroup.transform); } #if AssetBundleTools RuntimePanelGroup runtimeGroup = Object.FindObjectOfType <RuntimePanelGroup>(); if (runtimeGroup != null) { return(runtimeGroup.transform); } #endif if (prefab.GetComponent <RectTransform>() != null) { var canvas = GameObject.FindObjectOfType <Canvas>(); if (canvas != null) { return(canvas.transform); } var ok = EditorApplication.ExecuteMenuItem("GameObject/UI/Canvas"); if (ok) { var selected = Selection.activeTransform; return(selected); } } return(null); }