浏览代码

converted AssetSourceBase to an internal interface

/generic-asset-sources
sleal-unity 3 年前
当前提交
883033e7
共有 8 个文件被更改,包括 15 次插入9 次删除
  1. 2
      com.unity.perception/Editor/Randomization/Utilities/StaticData.cs
  2. 8
      com.unity.perception/Editor/Randomization/VisualElements/AssetSource/AssetSourceElement.cs
  3. 8
      com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/AssetRole.cs
  4. 2
      com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/AssetSource.cs
  5. 2
      com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/IAssetRoleBase.cs.meta
  6. 2
      com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/IAssetRoleBase.cs
  7. 0
      /com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/IAssetRoleBase.cs.meta
  8. 0
      /com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/IAssetRoleBase.cs

2
com.unity.perception/Editor/Randomization/Utilities/StaticData.cs


randomizerTypes = GetConstructableDerivedTypes<Randomizer>();
samplerTypes = GetConstructableDerivedTypes<ISampler>();
assetSourceLocationTypes = GetConstructableDerivedTypes<AssetSourceLocation>();
assetRoleTypes = GetConstructableDerivedTypes<AssetRoleBase>();
assetRoleTypes = GetConstructableDerivedTypes<IAssetRoleBase>();
}
static Type[] GetConstructableDerivedTypes<T>()

8
com.unity.perception/Editor/Randomization/VisualElements/AssetSource/AssetSourceElement.cs


Type m_AssetType;
Dictionary<string, Type> m_AssetRoleLabelsToTypes = new Dictionary<string, Type>();
AssetRoleBase assetRole =>
(AssetRoleBase)StaticData.GetManagedReferenceValue(m_AssetRoleProperty);
IAssetRoleBase assetRole =>
(IAssetRoleBase)StaticData.GetManagedReferenceValue(m_AssetRoleProperty);
AssetSourceLocation assetSourceLocation =>
(AssetSourceLocation)StaticData.GetManagedReferenceValue(m_LocationProperty);

else
{
m_AssetRoleToolbarMenu.text = GetAssetRoleDisplayName(type);
var newAssetRole = (AssetRoleBase)Activator.CreateInstance(type);
var newAssetRole = (IAssetRoleBase)Activator.CreateInstance(type);
m_AssetRoleProperty.managedReferenceValue = newAssetRole;
}
m_AssetRoleProperty.serializedObject.ApplyModifiedProperties();

static string GetAssetRoleDisplayName(Type type)
{
return $"{((AssetRoleBase)Activator.CreateInstance(type)).label} ({type.Name})";
return $"{((IAssetRoleBase)Activator.CreateInstance(type)).label} ({type.Name})";
}
}
}

8
com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/AssetRole.cs


/// Typed asset roles are used to apply preprocessing steps to assets loaded from an <see cref="AssetSource{T}"/>.
/// </summary>
/// <typeparam name="T">The type of asset to preprocess</typeparam>
public abstract class AssetRole<T> : AssetRoleBase where T : Object
public abstract class AssetRole<T> : IAssetRoleBase where T : Object
/// <inheritdoc/>
public abstract string label { get; }
/// <inheritdoc/>
public abstract string description { get; }
/// <summary>
/// Perform preprocessing operations on an asset loaded from an <see cref="AssetSource{T}"/>.
/// </summary>

2
com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/AssetSource.cs


[Serializable]
public sealed class AssetSource<T> where T : Object
{
[SerializeReference] AssetRoleBase m_AssetRoleBase;
[SerializeReference] IAssetRoleBase m_AssetRoleBase;
/// <summary>
/// The location to load assets from

2
com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/IAssetRoleBase.cs.meta


fileFormatVersion: 2
guid: 1af66eeef6ffa514a8307a228b8e85f9
guid: 7c335d3150918dc49be9cf2eddb144d2
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/IAssetRoleBase.cs


/// <summary>
/// The base asset role class. Derive from <see cref="AssetRole{T}"/> instead to create a new asset role.
/// </summary>
public abstract class AssetRoleBase
interface IAssetRoleBase
{
/// <summary>
/// The string label uniquely associated with this asset role

/com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/AssetRoleBase.cs.meta → /com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/IAssetRoleBase.cs.meta

/com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/AssetRoleBase.cs → /com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/IAssetRoleBase.cs

正在加载...
取消
保存