NavMeshSurface have some obsolete commands

Updated on April 14, 2020 in Unity
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on April 14, 2020

Hi everyone!

i recently added the .cs files shown in this video https://www.youtube.com/watch?v=CHV1ymlw-P8&t=149s to manage the creation of a NavMesh at runtime, but Unity says that there are several obsolete commands, such as UnityEditor.PrefabUtility.GetPrefabType(). I want to know if there is an updated version.

Thankyou in advance.

  • Liked by
Reply
0 on April 14, 2020

Update: i’ve tried to fix it by myself doing as below:

NavMeshSurface

replace this:

var prefabType = UnityEditor.PrefabUtility.GetPrefabType(this);
if (prefabType == UnityEditor.PrefabType.Prefab)

with this:

var prefabType = UnityEditor.PrefabUtility.GetPrefabAssetType(this);
 if (prefabType != UnityEditor.PrefabAssetType.NotAPrefab)

NavMeshSurfaceEditor

replace this:

var prefabType = PrefabUtility.GetPrefabType(navSurface);
if (prefabType == PrefabType.PrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance)

with this:

var prefabType = PrefabUtility.GetPrefabAssetType(navSurface);
 if (prefabType != PrefabAssetType.NotAPrefab)

while for GetPrefabParent() i’ve simply replaced it with GetCorrespondingObjectFromSource()…

It seems to work, but i don’t know if it covers all the possible cases…

What do you think?

  • Liked by
Reply
Cancel