提交 9af3291f 编写于 作者: A Adrian T

Fix compilation errors and warnings caused by prefabs-related changes in the API.

上级 b8468647
...@@ -45,7 +45,7 @@ void OnInspectorGUIPrefab(GameObject go) ...@@ -45,7 +45,7 @@ void OnInspectorGUIPrefab(GameObject go)
{ {
if (GUILayout.Button("Select the Prefab asset to bake or clear the navmesh", EditorStyles.helpBox)) if (GUILayout.Button("Select the Prefab asset to bake or clear the navmesh", EditorStyles.helpBox))
{ {
Selection.activeObject = PrefabUtility.GetPrefabParent(go); Selection.activeObject = PrefabUtility.GetCorrespondingObjectFromSource(go);
EditorGUIUtility.PingObject(Selection.activeObject); EditorGUIUtility.PingObject(Selection.activeObject);
} }
} }
...@@ -71,7 +71,7 @@ NavMeshData Build(NavMeshPrefabInstance instance) ...@@ -71,7 +71,7 @@ NavMeshData Build(NavMeshPrefabInstance instance)
var sources = new List<NavMeshBuildSource>(); var sources = new List<NavMeshBuildSource>();
var markups = new List<NavMeshBuildMarkup>(); var markups = new List<NavMeshBuildMarkup>();
NavMeshBuilder.CollectSources(root, ~0, NavMeshCollectGeometry.RenderMeshes, 0, markups, sources); NavMeshBuilder.CollectSources(root, ~0, NavMeshCollectGeometry.RenderMeshes, 0, markups, instance.gameObject.scene, sources);
var settings = NavMesh.GetSettingsByID(0); var settings = NavMesh.GetSettingsByID(0);
var bounds = new Bounds(Vector3.zero, 1000.0f * Vector3.one); var bounds = new Bounds(Vector3.zero, 1000.0f * Vector3.one);
var navmesh = NavMeshBuilder.BuildNavMeshData(settings, sources, bounds, root.position, root.rotation); var navmesh = NavMeshBuilder.BuildNavMeshData(settings, sources, bounds, root.position, root.rotation);
......
...@@ -110,11 +110,10 @@ static void CreateNavMeshAsset(NavMeshSurface surface) ...@@ -110,11 +110,10 @@ static void CreateNavMeshAsset(NavMeshSurface surface)
static NavMeshData GetNavMeshAssetToDelete(NavMeshSurface navSurface) static NavMeshData GetNavMeshAssetToDelete(NavMeshSurface navSurface)
{ {
var prefabType = PrefabUtility.GetPrefabType(navSurface); if (PrefabUtility.IsPartOfPrefabInstance(navSurface) && !PrefabUtility.IsPartOfModelPrefab(navSurface))
if (prefabType == PrefabType.PrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance)
{ {
// Don't allow deleting the asset belonging to the prefab parent // Don't allow deleting the asset belonging to the prefab parent
var parentSurface = PrefabUtility.GetPrefabParent(navSurface) as NavMeshSurface; var parentSurface = PrefabUtility.GetCorrespondingObjectFromSource(navSurface) as NavMeshSurface;
if (parentSurface && navSurface.navMeshData == parentSurface.navMeshData) if (parentSurface && navSurface.navMeshData == parentSurface.navMeshData)
return null; return null;
} }
......
using System.Collections.Generic; using System.Collections.Generic;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace UnityEngine.AI namespace UnityEngine.AI
{ {
...@@ -252,6 +254,7 @@ List<NavMeshBuildSource> CollectSources() ...@@ -252,6 +254,7 @@ List<NavMeshBuildSource> CollectSources()
modifiers = NavMeshModifier.activeModifiers; modifiers = NavMeshModifier.activeModifiers;
} }
var scene = gameObject.scene;
foreach (var m in modifiers) foreach (var m in modifiers)
{ {
if ((m_LayerMask & (1 << m.gameObject.layer)) == 0) if ((m_LayerMask & (1 << m.gameObject.layer)) == 0)
...@@ -268,17 +271,17 @@ List<NavMeshBuildSource> CollectSources() ...@@ -268,17 +271,17 @@ List<NavMeshBuildSource> CollectSources()
if (m_CollectObjects == CollectObjects.All) if (m_CollectObjects == CollectObjects.All)
{ {
NavMeshBuilder.CollectSources(null, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, sources); NavMeshBuilder.CollectSources(null, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, scene, sources);
} }
else if (m_CollectObjects == CollectObjects.Children) else if (m_CollectObjects == CollectObjects.Children)
{ {
NavMeshBuilder.CollectSources(transform, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, sources); NavMeshBuilder.CollectSources(transform, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, scene, sources);
} }
else if (m_CollectObjects == CollectObjects.Volume) else if (m_CollectObjects == CollectObjects.Volume)
{ {
Matrix4x4 localToWorld = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one); Matrix4x4 localToWorld = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
var worldBounds = GetWorldBounds(localToWorld, new Bounds(m_Center, m_Size)); var worldBounds = GetWorldBounds(localToWorld, new Bounds(m_Center, m_Size));
NavMeshBuilder.CollectSources(worldBounds, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, sources); NavMeshBuilder.CollectSources(worldBounds, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, scene, sources);
} }
if (m_IgnoreNavMeshAgent) if (m_IgnoreNavMeshAgent)
...@@ -368,8 +371,9 @@ bool UnshareNavMeshAsset() ...@@ -368,8 +371,9 @@ bool UnshareNavMeshAsset()
return false; return false;
// Prefab parent owns the asset reference // Prefab parent owns the asset reference
var prefabType = UnityEditor.PrefabUtility.GetPrefabType(this); var isInPreviewScene = EditorSceneManager.IsPreviewSceneObject(this);
if (prefabType == UnityEditor.PrefabType.Prefab) var isPersistentObject = EditorUtility.IsPersistent(this);
if (isInPreviewScene || isPersistentObject)
return false; return false;
// An instance can share asset reference only with its prefab parent // An instance can share asset reference only with its prefab parent
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册