@@ -32,32 +32,28 @@ public override void OnInspectorGUI()
32
32
33
33
EditorGUILayout . BeginHorizontal ( ) ;
34
34
EditorGUILayout . PropertyField ( person ) ;
35
- EditorGUIUtil . ObjectPickerField ( person ) ;
35
+ EditorGUIUtil . ObjectPickerField ( person , null , "Assets/AC" ) ;
36
36
EditorGUILayout . EndHorizontal ( ) ;
37
37
38
+ EditorGUILayout . BeginHorizontal ( ) ;
38
39
EditorGUILayout . PropertyField ( person2 ) ;
39
- EditorGUILayout . PropertyField ( person3 ) ;
40
- EditorGUILayout . PropertyField ( person4 ) ;
41
- if ( GUILayout . Button ( "选择对象" ) )
42
- {
43
- ObjectSelectorWindow . ShowObjectPicker < GameObject > ( person . objectReferenceValue , OnObjectPicker1 , "Assets/AC" ) ;
44
- }
45
- if ( GUILayout . Button ( "选择对象2" ) )
40
+ if ( GUILayout . Button ( "C" , EditorStyles . miniButton , GUILayout . Width ( 24f ) ) )
46
41
{
47
42
ObjectSelectorWindow . ShowObjectPicker < Sprite > ( person . objectReferenceValue , OnObjectPicker , "Assets" ) ;
48
43
}
44
+ EditorGUILayout . EndHorizontal ( ) ;
49
45
50
- if ( GUILayout . Button ( "选择对象3" ) )
46
+ EditorGUILayout . BeginHorizontal ( ) ;
47
+ EditorGUILayout . PropertyField ( person3 ) ;
48
+ if ( GUILayout . Button ( "C" , EditorStyles . miniButton , GUILayout . Width ( 24f ) ) )
51
49
{
52
50
ObjectSelectorWindow . ShowObjectPicker < AudioClip > ( person3 . objectReferenceValue , OnObjectPicker3 , "Assets/Sound" ) ;
53
51
}
52
+ EditorGUILayout . EndHorizontal ( ) ;
54
53
55
- if ( GUILayout . Button ( "选择对象4" ) )
56
- {
57
- EditorGUIUtility . ShowObjectPicker < GameObject > ( person . objectReferenceValue , false , String . Empty , 0 ) ;
58
- EditorApplication . update += updaterShow ;
59
- }
60
- if ( GUILayout . Button ( "选择对象5" ) )
54
+ EditorGUILayout . BeginHorizontal ( ) ;
55
+ EditorGUILayout . PropertyField ( person4 ) ;
56
+ if ( GUILayout . Button ( "C" , EditorStyles . miniButton , GUILayout . Width ( 24f ) ) )
61
57
{
62
58
GameObject go =
63
59
AssetDatabase . LoadAssetAtPath < GameObject > (
@@ -71,6 +67,8 @@ public override void OnInspectorGUI()
71
67
}
72
68
ObjectSelectorWindow . ShowObjectPicker < AnimationClip > ( person4 . objectReferenceValue , OnObjectPicker4 , "Assets/Standard Assets/Characters/ThirdPersonCharacter/Animation" , ids ) ;
73
69
}
70
+ EditorGUILayout . EndHorizontal ( ) ;
71
+
74
72
targetObj . ApplyModifiedProperties ( ) ;
75
73
}
76
74
@@ -103,45 +101,4 @@ private void OnObjectPicker(UnityEngine.Object obj)
103
101
Debug . Log ( "点中了空" ) ;
104
102
}
105
103
}
106
-
107
- private void updaterShow ( )
108
- {
109
- Debug . Log ( 1 ) ;
110
- if ( m_TimeNow < 0 )
111
- {
112
- m_TimeNow = EditorApplication . timeSinceStartup + 3f ;
113
- }
114
- if ( m_TimeNow <= EditorApplication . timeSinceStartup )
115
- {
116
- EditorApplication . update -= updaterShow ;
117
- Debug . Log ( 2 ) ;
118
- ShowPicker ( ) ;
119
- }
120
- }
121
-
122
- private void ShowPicker ( )
123
- {
124
- string m_RequiredType = typeof ( Sprite ) . Name ;
125
- Assembly assembly = Assembly . GetAssembly ( typeof ( EditorGUIUtility ) ) ;
126
- Type typeObjectSelector = assembly . GetType ( "UnityEditor.ObjectSelector" ) ;
127
- PropertyInfo get = typeObjectSelector . GetProperty ( "get" , BindingFlags . Static | BindingFlags . Public | BindingFlags . GetProperty ) ;
128
- FieldInfo listAreaInfo = typeObjectSelector . GetField ( "m_ListArea" , BindingFlags . GetField | BindingFlags . Instance | BindingFlags . NonPublic ) ;
129
- PropertyInfo listPositionInfo = typeObjectSelector . GetProperty ( "listPosition" ,
130
- BindingFlags . Instance | BindingFlags . GetProperty | BindingFlags . NonPublic ) ;
131
- EditorWindow objectSelector = get . GetValue ( null , null ) as EditorWindow ;
132
- object listArea = listAreaInfo . GetValue ( objectSelector ) ;
133
- object listPosition = listPositionInfo . GetValue ( objectSelector , null ) ;
134
-
135
- Type typeSearchFilter = assembly . GetType ( "UnityEditor.SearchFilter" ) ;
136
- object searchFilter = Activator . CreateInstance ( typeSearchFilter ) ;
137
- MethodInfo searchFieldStringToFilter = typeSearchFilter . GetMethod ( "SearchFieldStringToFilter" ,
138
- BindingFlags . Instance | BindingFlags . NonPublic ) ;
139
- PropertyInfo classNames = typeSearchFilter . GetProperty ( "classNames" ,
140
- BindingFlags . Instance | BindingFlags . Public | BindingFlags . GetProperty ) ;
141
- classNames . SetValue ( searchFilter , new string [ ] { m_RequiredType } , null ) ;
142
-
143
- Type typeObjectListArea = assembly . GetType ( "UnityEditor.ObjectListArea" ) ;
144
- MethodInfo initInfo = typeObjectListArea . GetMethod ( "Init" , BindingFlags . Instance | BindingFlags . Public ) ;
145
- initInfo . Invoke ( listArea , new object [ ] { listPosition , HierarchyType . Assets , searchFilter , true } ) ;
146
- }
147
104
}
0 commit comments