using UnityEngine; using UnityEditor; public class MenuEditor : MonoBehaviour { [MenuItem("Citizens PRO/Walking people")] private static void CreateWalkingPeople() { CreatePath(PathType.PeoplePath); } [MenuItem("Citizens PRO/Audience Path")] private static void CreateAudiencePath() { CreatePath(PathType.AudiencePath); } [MenuItem("Citizens PRO/Audience")] private static void CreateAudience() { var populationSystemManager = GetPopulationSystemManager(); Selection.activeGameObject = populationSystemManager.gameObject; ActiveEditorTracker.sharedTracker.isLocked = true; populationSystemManager.isConcert = true; } [MenuItem("Citizens PRO/Talking people")] private static void CreateTalkingPeople() { var populationSystemManager = GetPopulationSystemManager(); Selection.activeGameObject = populationSystemManager.gameObject; ActiveEditorTracker.sharedTracker.isLocked = true; populationSystemManager.isStreet = true; } private static void CreatePath(PathType pathType) { GetPopulationSystemManager(); GameObject newPath = new GameObject { name = "New path" }; NewPath newPathComponent = newPath.AddComponent(); newPathComponent.PathType = pathType; Selection.activeGameObject = newPath; } private static PopulationSystemManager GetPopulationSystemManager() { if (FindObjectOfType() == null) { string[] managerPrefabs = AssetDatabase.FindAssets("Population System t:Prefab"); if (managerPrefabs.Length > 0) { string managerPath = AssetDatabase.GUIDToAssetPath(managerPrefabs[0]); PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath(managerPath)); } } return FindObjectOfType(); } }