public override void OnInspectorGUI() { serializedObject.Update(); if (atlasProperty != null) { using (EditorGUILayout.HorizontalScope horizontalScope = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("Atlas", "DropDown", GUILayout.Width(EditorGUIUtility.labelWidth - 10)) == true) { AtlasSelector.Show(null, OnDoubleClickAtlas, atlasProperty.objectReferenceValue as UGUIAtlas); } //绘制图集属性 UGUIAtlas selectedAtlas = EditorGUILayout.ObjectField(atlasProperty.objectReferenceValue, typeof(UGUIAtlas), true) as UGUIAtlas; if (selectedAtlas != atlasProperty.objectReferenceValue) { atlasProperty.objectReferenceValue = selectedAtlas; spriteProperty.objectReferenceValue = null; serializedObject.ApplyModifiedProperties(); } } using (EditorGUILayout.HorizontalScope horizontalScope = new EditorGUILayout.HorizontalScope()) { var atlas = atlasProperty.objectReferenceValue as UGUIAtlas; if (atlas != null) { if (GUILayout.Button("Sprite", "DropDown", GUILayout.Width(EditorGUIUtility.labelWidth - 10)) == true) { AtlasSpriteSelector.Show(atlas, OnClickSprite, OnDoubleClickSprite, spriteProperty.objectReferenceValue as Sprite); } } else { GUILayout.Label("Sprite", GUILayout.Width(EditorGUIUtility.labelWidth - 10)); } using (EditorGUI.DisabledScope disableGroup = new EditorGUI.DisabledScope(atlas != null)) { using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope()) { EditorGUILayout.PropertyField(spriteProperty, new GUIContent("")); if (changeCheckScope.changed == true) { var newSprite = spriteProperty.objectReferenceValue as Sprite; if (newSprite) { Image.Type oldType = (Image.Type)typeProperty.enumValueIndex; if (newSprite.border.SqrMagnitude() > 0) { typeProperty.enumValueIndex = (int)Image.Type.Sliced; } else if (oldType == Image.Type.Sliced) { typeProperty.enumValueIndex = (int)Image.Type.Simple; } } } serializedObject.ApplyModifiedProperties(); } } } AppearanceControlsGUI(); RaycastControlsGUI(); showType.target = spriteProperty.objectReferenceValue != null; if (EditorGUILayout.BeginFadeGroup(showType.faded)) { TypeGUI(); } EditorGUILayout.EndFadeGroup(); SetShowNativeSize(true, true); if (EditorGUILayout.BeginFadeGroup(m_ShowNativeSize.faded)) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(preserveAspectProperty); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); NativeSizeButtonGUI(); serializedObject.ApplyModifiedProperties(); } }