private void OnEnable() { targetComponent = (target as NavMeshSourceTagImproved); IncludeChildren = serializedObject.FindProperty("IncludeChildren"); var parentTag = targetComponent.transform.parent? targetComponent.transform.parent.GetComponentInParent <NavMeshSourceTagImproved>() : null; if (parentTag != null && parentTag.IncludeChildren == true)//父节点有,并且勾选includeChildren,删除自己 { DestroyImmediate(targetComponent); EditorUtility.DisplayDialog("", "父节点中已经有一个NavMeshSourceTagUseAgentAndArea,并且勾选了IncludeChildren,此处不需要添加", "ok"); return; } m_childrenTmp.Clear(); targetComponent.GetComponentsInChildren <NavMeshSourceTagImproved>(m_childrenTmp); if (m_childrenTmp.Count > 1)//子节点有,includeChildren为false { IncludeChildren.boolValue = false; serializedObject.ApplyModifiedProperties(); //EditorUtility.DisplayDialog("", "子节点中有NavMeshSourceTagUseAgentAndArea,此处IncludeChildren只能为false", "ok"); } m_DefaultArea = serializedObject.FindProperty("m_DefaultArea"); m_AffectedAgents = serializedObject.FindProperty("m_AffectedAgents"); m_includeChildrenTmp = IncludeChildren.boolValue; }
void UpdateNavMesh(bool asyncUpdate = false) { NavMeshSourceTagImproved.Collect(ref m_Sources, agentTypeID); var buildSettings = NavMesh.GetSettingsByID(agentTypeID); var bounds = QuantizedBounds(); if (asyncUpdate) { m_Operation = NavMeshBuilder.UpdateNavMeshDataAsync(m_NavMesh, buildSettings, m_Sources, bounds); } else { NavMeshBuilder.UpdateNavMeshData(m_NavMesh, buildSettings, m_Sources, bounds); } }