Quantcast
Channel: Latest Questions by betaFlux
Viewing all articles
Browse latest Browse all 30

How to make builtin Component Inspector Settings available on Custom Component?

$
0
0
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(); 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.

Viewing all articles
Browse latest Browse all 30

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>