public override void OnInspectorGUI() { if (_isUIPrefab) { GameObject prefab = target as GameObject; if (!prefab) { return; } GUILayout.Label("UI Style: " + AssetDatabase.GetAssetPath(prefab)); RectTransform rt = prefab.transform as RectTransform; if (rt != null) { Rect r = rt.rect; GUILayout.Label("Size: " + r.width + ":" + r.height); } UIType ut = UIPrefabUtility.GetUIType(prefab); EditorGUI.BeginChangeCheck(); ut = (UIType)EditorGUILayout.EnumPopup("Type:", ut); if (EditorGUI.EndChangeCheck()) { UIPrefabUtility.SetUIType(prefab, ut); } bool enabled = UIPrefabUtility.GetUIModifactionProperty <bool>(prefab, UIUtiltiy.UI_ENABLE); EditorGUI.BeginChangeCheck(); enabled = EditorGUILayout.Toggle("Enable:", enabled); if (EditorGUI.EndChangeCheck()) { UIPrefabUtility.SetUIModitionProperty(prefab, UIUtiltiy.UI_ENABLE, enabled); } } }
public override void OnInspectorGUI() { DrawSeperator(); UIItemPanel b = style as UIItemPanel; if (b != null) { EditorGUI.BeginChangeCheck(); b.skinIndex = EditorGUILayout.DelayedIntField("Skin Index", b.skinIndex); _skinListDrawer.Draw(serializedObject); if (b.skinCount == 0) { EditorGUILayout.HelpBox("No Skin Picked", MessageType.Error); } else { for (int i = 0; i < b.skinCount; i++) { GameObject o = b.GetSkinAt(i); if (!o) { EditorGUILayout.HelpBox("skin 丢失", MessageType.Error); } else if (!UIPrefabUtility.IsFilterStyle(o, UIType.CellSkin)) { EditorGUILayout.HelpBox(string.Format("{0}不是cell skill", o.name), MessageType.Error); } } } EditorGUI.BeginChangeCheck(); int count = EditorGUILayout.DelayedIntField("Test Count:", b.length); if (EditorGUI.EndChangeCheck()) { if (count < 0) { count = 1; } object[] nt = new object[count]; for (int i = 0; i < count; i++) { nt[i] = new DataPaneTestData { name = "test_" + i }; } b.SetList(nt); } b.selectable = EditorGUILayout.Toggle("Selectable", b.selectable); b.allowMultipleSelecton = EditorGUILayout.Toggle("Multi Selectable", b.allowMultipleSelecton); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(b); } if (!b.GetComponent <GridLayoutCore>()) { EditorGUILayout.HelpBox("Layout 丢失", MessageType.Error); } GUILayout.Space(10); } }
private GameObject GetDraggngObject() { Object[] os = DragAndDrop.objectReferences; foreach (var o in os) { if (o is GameObject && UIPrefabUtility.IsFilterStyle(o as GameObject, _type)) { return(o as GameObject); } } return(null); }
internal void OnDestroy() { if (prefab) { if (UIPrefabUtility.GetUIType(prefab) == UIType.None) { EditorUtility.DisplayDialog("Miss UIType", "The UI Type can not be NONE, The Prefab will be delete!", "OK"); AssetDatabase.DeleteAsset(path); } } prefab = null; }
private static void HandlerPrefabAdd(string path, GameObject obj) { if (UIPrefabUtility.GetUIType(obj) == UIType.None) { UITypeEditor window = EditorWindow.GetWindow <UITypeEditor>(true); window.maxSize = window.minSize = new Vector2(220, 110); var postion = window.position; postion.center = new Rect(0f, 0f, Screen.currentResolution.width, Screen.currentResolution.height).center; window.position = postion; window.prefab = obj; window.path = path; } }
internal void OnGUI() { UIType ut = UIPrefabUtility.GetUIType(prefab); GUILayout.Space(5); GUILayout.TextArea("this is Very important to pick the type of the UI Style for further usage", GUILayout.Height(50)); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Label("Type:", GUILayout.MaxWidth(60)); EditorGUI.BeginChangeCheck(); ut = (UIType)EditorGUILayout.EnumPopup("", ut, GUILayout.MaxWidth(160)); if (EditorGUI.EndChangeCheck()) { errMsg.Clear(); if (UIPrefabUtility.CheckUIPrefabValidation(prefab, ut, errMsg)) { string msg = Enum.GetName(typeof(UIType), ut) + " need Component below:\n" + string.Join(",", errMsg.ToArray()); EditorUtility.DisplayDialog("Invalidate Type", msg, "OK"); ut = UIType.None; UIPrefabUtility.SetUIModitionProperty(prefab, UIUtiltiy.UI_TYPE, ut); } else { UIPrefabUtility.SetUIModitionProperty(prefab, UIUtiltiy.UI_TYPE, ut); } } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Apply", GUILayout.MaxWidth(100), GUILayout.Height(20))) { if (ut == UIType.None) { EditorUtility.DisplayDialog("warning", "ui type cannot be none", "ok"); } else { UIPrefabUtility.SetUIModitionProperty(prefab, UIUtiltiy.UI_ENABLE, true); AssetDatabase.Refresh(); Close(); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(10); }
public void OnEnable() { DestroyPreview(); GameObject p = target as GameObject; _isUIPrefab = UIPrefabUtility.IsUIPrefab(p); if (_isUIPrefab && p != null) { _baseRect = p.GetComponent <RectTransform>().rect; if (!previewer) { previewer = new UIPreivewUtility(); } } }
private static void RegisterPrefabChecker() { UIPrefabUtility.AddCheckType <Panel>(UIType.Panel, false); UIPrefabUtility.AddCheckType <PButton>(UIType.Button, false); UIPrefabUtility.AddCheckType <Tab>(UIType.TabNavigator, false); UIPrefabUtility.AddCheckType <PToggle>(UIType.Checkbox, false); UIPrefabUtility.AddCheckType <PToggle>(UIType.RadioButton, false); UIPrefabUtility.AddCheckType <PDropdown>(UIType.Combobox, false); UIPrefabUtility.AddCheckType <Slider>(UIType.Slider, false); UIPrefabUtility.AddCheckType <Bar>(UIType.Bar, false); UIPrefabUtility.AddCheckType <Star>(UIType.Star, false); UIPrefabUtility.AddCheckType <ResourceField>(UIType.ResourceField, false); UIPrefabUtility.AddCheckType <ScrollView>(UIType.DataPane, false); UIPrefabUtility.AddCheckType(UIType.DataPane, CheckScrollBar); UIPrefabUtility.AddCheckType <ScrollView>(UIType.TreePane, false); UIPrefabUtility.AddCheckType(UIType.TreePane, CheckScrollBar); UIPrefabUtility.AddCheckType(UIType.TextArea, CheckScrollBar); UIPrefabUtility.AddCheckType <ScrollView>(UIType.TextArea, false); UIPrefabUtility.AddCheckType <PText>(UIType.TextArea, true); UIPrefabUtility.AddCheckType <InputField>(UIType.TextInput, true); UIPrefabUtility.AddCheckType <PText>(UIType.TextInput, true); }
public override void OnInspectorGUI() { _picker.Draw(style); DrawSeperator(); UIDataPane b = style as UIDataPane; if (b != null) { EditorGUI.BeginChangeCheck(); _scrollDrawer.Draw(b.scrollSetting, b); DrawSeperator(); b.skinIndex = EditorGUILayout.DelayedIntField("Skin Index", b.skinIndex); _listDrawer.Draw(serializedObject); if (b.skinCount == 0) { EditorGUILayout.HelpBox("No Skin Picked", MessageType.Error); } else { for (int i = 0; i < b.skinCount; i++) { GameObject o = b.GetSkinAt(i); if (!o) { EditorGUILayout.HelpBox("skin 丢失", MessageType.Error); } else if (!UIPrefabUtility.IsFilterStyle(o, UIType.CellSkin)) { EditorGUILayout.HelpBox(string.Format("{0}不是cell skill", o.name), MessageType.Error); } } } DrawSeperator(); EditorGUI.BeginChangeCheck(); int count = EditorGUILayout.DelayedIntField("Test Count:", b.length); if (EditorGUI.EndChangeCheck()) { if (count < 0) { count = 1; } object[] nt = new object[count]; for (int i = 0; i < count; i++) { nt[i] = new DataPaneTestData { name = "test_" + i }; } b.SetList(nt); } b.selectable = EditorGUILayout.Toggle("Selectable", b.selectable); b.allowMultipleSelecton = EditorGUILayout.Toggle("Multi Selectable", b.allowMultipleSelecton); EditorGUILayout.LabelField("Border (Left, Top, Right, Bottom)"); b.border = EditorGUILayout.Vector4Field("", b.border); GUILayout.Space(10); b.controlObj = (UICore)EditorGUILayout.ObjectField("Pager Host", b.controlObj, typeof(UICore), true); if (b.controlObj && !(b.controlObj is ISelectableContainer)) { EditorGUILayout.HelpBox( "control host must be typeof (ISelectableUIContainer) include:\r\n\tTabNavigaor\r\n\tDataPane\r\r\tItemPane", MessageType.Warning); } if (!b.GetComponent <GridLayoutCore>()) { EditorGUILayout.HelpBox("Layout 丢失", MessageType.Error); } GUILayout.Space(10); } }