- Home /
Question by
betaFlux · Jan 26, 2014 at 05:31 PM ·
inspectornavmeshagentcomponentsettings
How to make builtin Component Inspector Settings available on Custom Component?
Hello,
I have a portal script on an empty gameobject in the scene that spawns character prefabs with the 'NavMeshAgent' component attached. Is it possible to make certain builtin NavMeshAgent Settings available on the portal script, so that it automatically adjusts the settings of the NavMeshAgent component of the instantiated prefabs?
This, for example, is how I change the ObstacleAvoidanceType enum on game start:
public GameObject agentPrefab;
public enum DynamicAvoidanceQuality
{
None, Low, Medium, Good, High
}
public DynamicAvoidanceQuality dynamicAvoidanceQuality = DynamicAvoidanceQuality.High;
void Start()
{
NavMeshAgent navMeshAgent = agentPrefab.GetComponent<NavMeshAgent>();
switch(dynamicAvoidanceQuality)
{
case ObstacleAvoidanceQuality.None: navMeshAgent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance; break;
case ObstacleAvoidanceQuality.Low: navMeshAgent.obstacleAvoidanceType = ObstacleAvoidanceType.LowQualityObstacleAvoidance; break;
case ObstacleAvoidanceQuality.Medium: navMeshAgent.obstacleAvoidanceType = ObstacleAvoidanceType.MedQualityObstacleAvoidance; break;
case ObstacleAvoidanceQuality.Good: navMeshAgent.obstacleAvoidanceType = ObstacleAvoidanceType.GoodQualityObstacleAvoidance; break;
case ObstacleAvoidanceQuality.High: navMeshAgent.obstacleAvoidanceType = ObstacleAvoidanceType.HighQualityObstacleAvoidance; break;
}
}
It works, but I hope somebody will teach me better.
Comment