コード例 #1
0
 public static bool ObjectPickerField(SerializedProperty property, Action <UnityEngine.Object> itemSelectedCallback = null, string folderPath = "Assets")
 {
     if (GUILayout.Button("C", EditorStyles.miniButton, GUILayout.Width(24f)))
     {
         ObjectSelectorWindow.ShowObjectPicker(property, itemSelectedCallback, folderPath);
     }
     return(true);
 }
コード例 #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            float w = position.width;

            position.width = w - 16;
            EditorGUI.PropertyField(position, property);

            position.x    += position.width;
            position.width = 16;
            if (GUI.Button(position, "s", EditorStyles.miniButton))
            {
                ObjectSelecterAttribute selecterAttribute = attribute as ObjectSelecterAttribute;
                //Type extention = selecterAttribute.type;
                ObjectSelectorWindow.ShowObjectPicker(selecterAttribute.type, property.objectReferenceValue, property, null,
                                                      selecterAttribute.path);
            }
        }
コード例 #3
0
    public override void OnInspectorGUI()
    {
        targetObj.Update();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(person);
        EditorGUIUtil.ObjectPickerField(person, null, "Assets/AC");
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(person2);
        if (GUILayout.Button("C", EditorStyles.miniButton, GUILayout.Width(24f)))
        {
            ObjectSelectorWindow.ShowObjectPicker <Sprite>(person.objectReferenceValue, OnObjectPicker, "Assets");
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(person3);
        if (GUILayout.Button("C", EditorStyles.miniButton, GUILayout.Width(24f)))
        {
            ObjectSelectorWindow.ShowObjectPicker <AudioClip>(person3.objectReferenceValue, OnObjectPicker3, "Assets/Sound");
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(person4);
        if (GUILayout.Button("C", EditorStyles.miniButton, GUILayout.Width(24f)))
        {
            GameObject go =
                AssetDatabase.LoadAssetAtPath <GameObject>(
                    "Assets/Standard Assets/Characters/ThirdPersonCharacter/Prefabs/ThirdPersonController.prefab");

            AnimationClip[] clips = AnimationUtility.GetAnimationClips(go);
            List <int>      ids   = new List <int>();
            foreach (var clip in clips)
            {
                ids.Add(clip.GetInstanceID());
            }
            ObjectSelectorWindow.ShowObjectPicker <AnimationClip>(person4.objectReferenceValue, OnObjectPicker4, "Assets/Standard Assets/Characters/ThirdPersonCharacter/Animation", ids);
        }
        EditorGUILayout.EndHorizontal();

        targetObj.ApplyModifiedProperties();
    }