Search Issue Tracker
Fixed in 2018.3.X
Fixed in 2017.3.X
Votes
0
Found in
2017.3.0f3
Issue ID
1012200
Regression
No
ScriptedImporter's SerializedProperty.objectReferenceValue can't be set in Inspector
Editing UnityEngine.Object fields (like Material, GameObject, etc) of a custom ScriptedImporter do not work in a default Inspector. This might be tied to the fact that setting SerializedProperty.objectReferenceValue property for these fields doesn't work. However, as a workaround, it is possible to set those fields directly through custom inspector editor, and they are correctly serialized to a meta file.
To reproduce:
1. Download attached project "BugScriptedImporterSerializedProperty.zip" and open in Unity
2. Open "BugScriptedImporterSerializedProperty" scene
3. Open "MyImporter.cs script" and observe that it has "Int", "Material" and "Prefab" fields
4. Select "asset.myasset" asset in the Project window
5. Try to edit "Int" field and observe that it can be edited
6. Try to edit "Material" and "Prefab" fields and observe that they can't be edited, nor they accept Dragged & Dropped assets
The likely reason why this doesn't work and Workaround:
1. Open "MyImporterEditor.cs" script and comment out the "#define DISABLE" line
Note: This will enable a custom editor for the asset
2. Inspect "asset.myasset.meta" file, and observe that serialized "Material" and "Prefab" fields do not reference any assets
3. Select "asset.myasset" asset in the Project window
4. Observe that first two fields showed through default EditorGUILayout.PropertyField are not editable and they don't accept Dragged & Dropped assets - just like in default Inspector
5. Observe that next two fields (custom field), showed through custom EditorGUILayout.ObjectField can accept Dragged & Dropped assets, but "materialProperty.objectReferenceValue = newMaterial;" line doesn't work, so fields remain unset
Note: Through above steps, it's impossible to modify those fields and get them to serialize to "asset.myasset.meta" file
6. Observe that next two fields (direct field), that set fields directly work correctly.
7. Set those fields, hit "Apply", inspect "asset.myasset.meta" file, and see that those fields were serialized correctly
Notes:
- This issue appears on Windows and OSX
- In Unity 2018.1 and 2018.2 this issue is fixed
Reproduced on Unity 2017.3.0a7, 2017.3.0f3, 2017.3.2f1 and 2017.4.0f1
Could not reproduce on Unity 2018.1.0b12 and 2018.2.0a5
Could not check for regression on Unity 2017.1, 2017.2 and 2017.3.0a6 because project becomes corrupted
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- "Unexpected exception System.DllNotFoundException" error thrown in the Console window when creating a project with 2D (URP) Template
- [Backport] [XR SDK] [HDRP] XRSettings.gameViewRenderMode does not change Game View Render Mode
- [Backport] [Android][Vulkan] Crash on Samsung Note8 while running gfx tests
- [Backport] Wrong sorting for "GC Alloc" column in Show Related Objects panel of Profiler Window
- [Backport] [iOS] Unfreed allocation errors thrown in Console when executing Build And Run with iOS platform
songerald6
May 08, 2022 09:06
Hopefully, I will be able to share this method with my followers. Hopefully, it will help for them.
SilviaBell
Sep 10, 2021 08:45
Thank you for sharing you can download <a href="Cinemahdplus.com">cinema hd app</a> completely free here to watch exciting movies
SilviaBell
Sep 10, 2021 08:44
Thank you for sharing you can download Cinema HD completely free here CinemaHDPlus.Com to watch exciting movies
mralikhalaf
Apr 17, 2021 10:00
A very beautiful blog, in addition to its speed, such as
lukashik
Mar 30, 2021 17:48
It's good that I found your article. A friend of mine recently ran into this problem, but in my opinion never found a solution. I will now share your link on GBWhatsApp pipsli.net
Hope this is exactly what he was looking for. Thanks in advance
lukashik
Mar 30, 2021 17:47
It's good that I found your article. A friend of mine recently ran into this problem, but in my opinion never found a solution. I will now share your link on GBWhatsApp
Hope this is exactly what he was looking for. Thanks in advance
sanisk
Sep 26, 2020 13:54
gg
annaq2e
Sep 20, 2020 19:10
hi
lolee1942ja
Sep 20, 2020 14:08
Good post!
runahead456
Jul 15, 2020 01:17
If successful, I will share this news with friends on YoWhatsapp( download free at https://apkrapido.com/yowhatsapp/ ). Thanks for sharing.