浏览代码

addressables updates

/addressables-test
sleal-unity 4 年前
当前提交
ec307e93
共有 4 个文件被更改,包括 51 次插入4 次删除
  1. 7
      com.unity.perception/Editor/Randomization/Editors/ScenarioBaseEditor.cs
  2. 2
      com.unity.perception/Editor/Randomization/Uxml/ScenarioBaseElement.uxml
  3. 28
      com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
  4. 18
      com.unity.perception/Runtime/Randomization/Scenarios/Serialization/ScenarioSerializer.cs

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


using System.IO;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.Perception.Randomization.Scenarios;
using UnityEngine.UIElements;

"Using undo in the editor will revert these changes to your scenario.");
PlayerPrefs.SetString(k_ConfigFilePlayerPrefKey, filePath);
};
var appParamField = new ObjectField();
appParamField.objectType = typeof(TextAsset);
appParamField.BindProperty(serializedObject.FindProperty(nameof(ScenarioBase.testAppParam)));
var scenarioPropertiesContainer = m_Root.Q<VisualElement>("scenario-properties-container");
scenarioPropertiesContainer.Add(appParamField);
return m_Root;
}

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


<VisualElement>
<Style src="../Uss/Styles.uss"/>
<VisualElement name="inspector-properties" style="margin-bottom: 4px;"/>
<VisualElement class="scenario__dark-viewport" >
<VisualElement name="scenario-properties-container" class="scenario__dark-viewport" >
<TextElement text="Scenario Properties" class="scenario__title-label"/>
<TextElement
class="scenario__info-box"

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


}
}
#if UNITY_EDITOR
public TextAsset testAppParam;
#endif
protected List<string> m_CatalogUrls = new List<string>();
protected Dictionary<string, string> m_BundleToUrlMap = new Dictionary<string, string>();
/// <summary>
/// The current activity state of the scenario
/// </summary>

/// </summary>
protected virtual void OnConfigurationImport()
{
#if !UNITY_EDITOR
#if UNITY_EDITOR
if (testAppParam != null)
{
DeserializeFromFile(AssetDatabase.GetAssetPath(testAppParam));
}
#else
DeserializeFromCommandLine();
#endif
}

void Awake()
{
activeScenario = this;
OnAwake();
OnConfigurationImport();
OnAwake();
}
/// <summary>

case State.Initializing:
if (isScenarioReadyToStart)
{
OnConfigurationImport();
state = State.Playing;
OnStart();
foreach (var randomizer in m_Randomizers)

if (randomizer is T typedRandomizer)
return typedRandomizer;
throw new ScenarioException($"A Randomizer of type {typeof(T).Name} was not added to this scenario");
}
public void AddBundleUrl(string bundle, string url)
{
m_BundleToUrlMap.Add(bundle, url);
}
public void AddCatalogUrl(string url)
{
m_CatalogUrls.Add(url);
}
void ValidateParameters()

18
com.unity.perception/Runtime/Randomization/Scenarios/Serialization/ScenarioSerializer.cs


public static void Deserialize(ScenarioBase scenario, string json)
{
var jsonData = JObject.Parse(json);
if (jsonData.ContainsKey("contents"))
DeserializeContents(scenario, (JObject)jsonData["contents"]);
if (jsonData.ContainsKey("constants"))
DeserializeConstants(scenario.genericConstants, (JObject)jsonData["constants"]);
if (jsonData.ContainsKey("randomizers"))

static void DeserializeContents(ScenarioBase scenario, JObject contentsData)
{
var catalogs = (JArray)contentsData["catalogs"];
foreach (var catalogToken in catalogs)
{
var catalog = (JObject)catalogToken;
scenario.AddCatalogUrl(catalog["catalogUrl"].Value<string>());
var bundles = (JArray) catalog["bundles"];
foreach (var bundleToken in bundles)
{
var bundle = (JObject) bundleToken;
scenario.AddBundleUrl(bundle["name"].Value<string>(), bundle["url"].Value<string>());
}
}
}
static void DeserializeConstants(ScenarioConstants constants, JObject constantsData)
{
var serializer = new JsonSerializer();

正在加载...
取消
保存