浏览代码

updated tooltips for scenario serialization buttons

/main
Steven Leal 4 年前
当前提交
ba332ad8
共有 4 个文件被更改,包括 22 次插入15 次删除
  1. 14
      com.unity.perception/Editor/Randomization/Editors/ScenarioBaseEditor.cs
  2. 6
      com.unity.perception/Editor/Randomization/Uxml/ScenarioBaseElement.uxml
  3. 6
      com.unity.perception/Runtime/Randomization/Scenarios/Scenario.cs
  4. 11
      com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs

14
com.unity.perception/Editor/Randomization/Editors/ScenarioBaseEditor.cs


m_Root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
$"{StaticData.uxmlDir}/ScenarioBaseElement.uxml").CloneTree();
var serializeConstantsButton = m_Root.Q<Button>("serialize-constants");
m_RandomizerListPlaceholder = m_Root.Q<VisualElement>("randomizer-list-placeholder");
CreatePropertyFields();
CheckIfConstantsExist();
var serializeConstantsButton = m_Root.Q<Button>("serialize");
serializeConstantsButton.clicked += () =>
{
m_Scenario.SerializeToFile();

};
var deserializeConstantsButton = m_Root.Q<Button>("deserialize-constants");
var deserializeConstantsButton = m_Root.Q<Button>("deserialize");
m_RandomizerListPlaceholder = m_Root.Q<VisualElement>("randomizer-list-placeholder");
CreatePropertyFields();
CheckIfConstantsExist();
return m_Root;
}

6
com.unity.perception/Editor/Randomization/Uxml/ScenarioBaseElement.uxml


tooltip="A list of parameters for this scenario that will be JSON serialized."/>
<editor:PropertyField name="configuration-file-name" label="Constants File Name" binding-path="serializedConstantsFileName"/>
<VisualElement style="flex-direction: row;">
<Button name="serialize-constants" text="Serialize Constants" style="flex-grow: 1;"/>
<Button name="deserialize-constants" text="Deserialize Constants" style="flex-grow: 1;"/>
<Button name="serialize" text="Serialize To Config File" style="flex-grow: 1;"
tooltip="Serializes scenario constants and randomizer settings to a JSON configuration file"/>
<Button name="deserialize" text="Deserialize From Config File" style="flex-grow: 1;"
tooltip="Deserializes scenario constants and randomizer settings from a scenario_configuration.json file located in the Assets/StreamingAssets project folder"/>
</VisualElement>
</VisualElement>
</VisualElement>

6
com.unity.perception/Runtime/Randomization/Scenarios/Scenario.cs


throw new ArgumentNullException();
if (!File.Exists(configFilePath))
throw new FileNotFoundException($"A scenario configuration file does not exist at path {configFilePath}");
#if UNITY_EDITOR
Debug.Log($"Deserialized scenario configuration from <a href=\"file:///${configFilePath}\">{configFilePath}</a>. " +
"Using undo in the editor will revert these changes to your scenario.");
#else
#endif
var jsonText = File.ReadAllText(configFilePath);
DeserializeFromJson(jsonText);
}

11
com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs


/// <summary>
/// The name of the Json file this scenario's constants are serialized to/from.
/// </summary>
public virtual string configFileName => "constants";
public virtual string configFileName => "scenario_configuration";
/// <summary>
/// Returns the active parameter scenario in the scene

}
/// <summary>
/// Returns the asset location of the JSON serialized constants.
/// Returns the asset location of the JSON serialized configuration.
/// This API is used for finding the config file using the AssetDatabase API.
/// </summary>
public string defaultConfigFileAssetPath =>

/// Returns the absolute file path of the JSON serialized constants
/// Returns the absolute file path of the JSON serialized configuration
/// </summary>
public string defaultConfigFilePath =>
Application.dataPath + "/StreamingAssets/" + configFileName + ".json";

}
/// <summary>
/// Serializes the scenario's constants and randomizer configuration to a JSON string
/// Serializes the scenario's constants and randomizer settings to a JSON string
/// Serializes the scenario's constants to a JSON file located at serializedConstantsFilePath
/// Serializes the scenario's constants and randomizer settings to a JSON file located at the path resolved by
/// the defaultConfigFilePath scenario property
/// </summary>
public void SerializeToFile()
{

正在加载...
取消
保存