|
|
|
|
|
|
string m_BuildZipPath; |
|
|
|
SysParamDefinition[] m_SysParamDefinitions; |
|
|
|
IntegerField m_InstanceCountField; |
|
|
|
Button m_RunButton; |
|
|
|
IntegerField m_TotalIterationsField; |
|
|
|
IntegerField m_TotalIterationsField; |
|
|
|
ObjectField m_ScenarioConfig; |
|
|
|
Button m_RunButton; |
|
|
|
TextAsset scenarioConfig => (TextAsset)m_ScenarioConfig.value; |
|
|
|
string scenarioConfigAssetPath => AssetDatabase.GetAssetPath(scenarioConfig); |
|
|
|
|
|
|
|
[MenuItem("Window/Run in Unity Simulation")] |
|
|
|
static void ShowWindow() |
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ScenarioConfig = root.Q<ObjectField>("scenario-config"); |
|
|
|
m_ScenarioConfig.objectType = typeof(TextAsset); |
|
|
|
var configPath = PlayerPrefs.GetString("SimWindow/scenarioConfig"); |
|
|
|
if (configPath != string.Empty) |
|
|
|
m_ScenarioConfig.value = AssetDatabase.LoadAssetAtPath<TextAsset>(configPath); |
|
|
|
|
|
|
|
m_RunButton = root.Q<Button>("run-button"); |
|
|
|
m_RunButton.clicked += RunInUnitySimulation; |
|
|
|
|
|
|
|
|
|
|
if (!StaticData.IsSubclassOfRawGeneric(typeof(UnitySimulationScenario<>), currentScenario.GetType())) |
|
|
|
throw new NotSupportedException( |
|
|
|
"Scenario class must be derived from UnitySimulationScenario to run in Unity Simulation"); |
|
|
|
if (scenarioConfig != null && Path.GetExtension(scenarioConfigAssetPath) != ".json") |
|
|
|
throw new NotSupportedException( |
|
|
|
"Scenario configuration must be a JSON text asset"); |
|
|
|
} |
|
|
|
|
|
|
|
void SetNewPlayerPreferences() |
|
|
|
|
|
|
PlayerPrefs.SetInt("SimWindow/instanceCount", m_InstanceCountField.value); |
|
|
|
PlayerPrefs.SetInt("SimWindow/sysParamIndex", m_SysParamIndex); |
|
|
|
PlayerPrefs.SetString("SimWindow/scenarioConfig", |
|
|
|
scenarioConfig != null ? scenarioConfigAssetPath : string.Empty); |
|
|
|
} |
|
|
|
|
|
|
|
void CreateLinuxBuildAndZip() |
|
|
|
|
|
|
List<AppParam> GenerateAppParamIds(CancellationToken token, float progressStart, float progressEnd) |
|
|
|
{ |
|
|
|
var appParamIds = new List<AppParam>(); |
|
|
|
var configuration = JObject.Parse(currentScenario.SerializeToJson()); |
|
|
|
var configuration = JObject.Parse(scenarioConfig != null |
|
|
|
? File.ReadAllText(scenarioConfigAssetPath) |
|
|
|
: currentScenario.SerializeToJson()); |
|
|
|
var constants = configuration["constants"]; |
|
|
|
|
|
|
|
constants["totalIterations"] = m_TotalIterationsField.value; |
|
|
|