public void LoadPrefabs() { var directory = EngineSettings.GetSettingsSubDirectory("Prefabs"); var files = Directory.GetFiles(directory, "*.bspref"); CurrentProject.Prefabs.Clear(); foreach (var file in files) { var prefab = JsonSerializable.Load <BlueSwitchProject>(file); CurrentProject.Prefabs.Add(new Prefab { Project = prefab, Name = prefab.Name, Description = prefab.Description, FilePath = prefab.FilePath }); } foreach (var p in CurrentProject.Prefabs) { PrefabSwitch sw = new PrefabSwitch(); sw.Prefab = p; sw.InitializeMetaInformation(this); sw.Initialize(this); sw.AutoDiscoverDisabled = false; var available = AvailableSwitches.FirstOrDefault(x => x.GetType() == sw.GetType()); // This should probably be refactored to a central spot for AvailableSwitches if (available != null) { AvailableSwitches.Remove(available); // Refresh prefab switches from list } AvailableSwitches.Add(sw); } }
/// <summary>Calls on drawing the GUI for the inspector.</summary> public override void OnInspectorGUI() { // Draw the default inspector. DrawDefaultInspector(); // Grab a reference to the target script, so we can identify it as a // PrefabSwitch, instead of a simple Object. PrefabSwitch prefabSwitch = (PrefabSwitch)target; // Create a Button for "Swap By Tag", if (GUILayout.Button("Swap By Tag")) { // if it is clicked, call the SwapAllByTag method from prefabSwitch. prefabSwitch.SwapAllByTag(); } // Create a Button for "Swap By Array", if (GUILayout.Button("Swap By Array")) { // if it is clicked, call the SwapAllByArray method from prefabSwitch. prefabSwitch.SwapAllByArray(); } }