浏览代码

added xml docs to new classes

/generic-asset-sources
sleal-unity 3 年前
当前提交
39d2594b
共有 9 个文件被更改,包括 111 次插入28 次删除
  1. 2
      com.unity.perception/Editor/Randomization/PropertyDrawers/AssetSourceDrawer.cs
  2. 2
      com.unity.perception/Editor/Randomization/VisualElements/AssetSource/AssetListElement.cs
  3. 2
      com.unity.perception/Editor/Randomization/VisualElements/Basic/UIntField.cs
  4. 2
      com.unity.perception/Editor/Randomization/VisualElements/Basic/UxmlUIntAttributeDescription.cs
  5. 16
      com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/Archetype.cs
  6. 8
      com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/ArchetypeBase.cs
  7. 73
      com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/AssetSource.cs
  8. 22
      com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/AssetSourceLocation.cs
  9. 12
      com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/LocalAssetSourceLocation.cs

2
com.unity.perception/Editor/Randomization/PropertyDrawers/AssetSourceDrawer.cs


namespace UnityEditor.Perception.Randomization.PropertyDrawers
{
[CustomPropertyDrawer(typeof(AssetSource<>))]
public class AssetSourceDrawer : PropertyDrawer
class AssetSourceDrawer : PropertyDrawer
{
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{

2
com.unity.perception/Editor/Randomization/VisualElements/AssetSource/AssetListElement.cs


namespace Editor.Randomization.VisualElements.AssetSource
{
public class AssetListElement : VisualElement
class AssetListElement : VisualElement
{
SerializedProperty m_Property;
IList list => (IList)StaticData.GetManagedReferenceValue(m_Property);

2
com.unity.perception/Editor/Randomization/VisualElements/Basic/UIntField.cs


/// <summary>
/// <para>Makes a text field for entering an unsigned integer.</para>
/// </summary>
public class UIntField : TextValueField<uint>
class UIntField : TextValueField<uint>
{
/// <summary>
/// <para>USS class name of elements of this type.</para>

2
com.unity.perception/Editor/Randomization/VisualElements/Basic/UxmlUIntAttributeDescription.cs


/// <summary>
/// <para>Describes a XML int attribute.</para>
/// </summary>
public class UxmlUIntAttributeDescription : TypedUxmlAttributeDescription<uint>
class UxmlUIntAttributeDescription : TypedUxmlAttributeDescription<uint>
{
/// <summary>
/// <para>Constructor.</para>

16
com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/Archetype.cs


namespace UnityEngine.Perception.Randomization
{
/// <summary>
/// Derive this class to create a typed Archetype.
/// Typed Archetypes 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 void Preprocess(T item);
public override void PreprocessAsset(Object asset)
{
Preprocess((T)asset);
}
/// <summary>
/// Perform preprocessing operations on an asset loaded from an <see cref="AssetSource{T}"/>.
/// </summary>
/// <param name="asset">The asset to preprocess</param>
public abstract void Preprocess(T asset);
}
}

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


namespace UnityEngine.Perception.Randomization
{
/// <summary>
/// The base Archetype class. Derive from <see cref="AssetSource{T}"/> instead to create a new archetype.
/// </summary>
/// <summary>
/// The string label uniquely associated with this archetype
/// </summary>
public abstract void PreprocessAsset(Object asset);
}
}

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


namespace UnityEngine.Perception.Randomization
{
/// <summary>
/// AssetSources are used to load assets from a generically within a <see cref="Randomizers.Randomizer"/>
/// </summary>
/// <typeparam name="T">The type of asset to load</typeparam>
[SerializeReference] ArchetypeBase m_ArchetypeBase;
/// <summary>
/// The location to load assets from
/// </summary>
[SerializeReference] public AssetSourceLocation assetSourceLocation = new LocalAssetSourceLocation();
[SerializeReference] ArchetypeBase m_ArchetypeBase;
[SerializeReference] public AssetSourceLocation assetSourceLocation = new LocalAssetSourceLocation();
/// <summary>
/// The archetype used to preprocess assets from this source
/// </summary>
public Archetype<T> archetype
{
get => (Archetype<T>)m_ArchetypeBase;

/// <summary>
/// The number of assets available within this asset source
/// </summary>
/// <summary>
/// Execute setup steps for this AssetSource
/// </summary>
public void Initialize()
{
assetSourceLocation.Initialize(archetype);

public T GetAsset(int index)
/// <summary>
/// Returns the asset loaded from the provided index
/// </summary>
/// <param name="index">The index of the asset to load</param>
/// <returns>The asset loaded at the provided index</returns>
public T LoadAsset(int index)
return assetSourceLocation.GetAsset<T>(index);
return assetSourceLocation.LoadAsset<T>(index);
public T[] GetAssets()
/// <summary>
/// Returns all assets that can be loaded from this AssetSource
/// </summary>
/// <returns>All assets that can be loaded from this AssetSource</returns>
public T[] LoadAllAssets()
array[i] = GetAsset(i);
array[i] = LoadAsset(i);
public T GetInstance(int index)
/// <summary>
/// Creates an instance of the asset loaded from the provided index
/// </summary>
/// <param name="index">The index of the asset to load</param>
/// <returns>The instantiated instance</returns>
public T CreateInstance(int index)
return CreateInstance(GetAsset(index));
return CreateInstance(LoadAsset(index));
public T[] GetInstances()
/// <summary>
/// Instantiates and returns all assets that can be loaded from this asset source
/// </summary>
/// <returns>Instantiated instances from every loadable asset</returns>
public T[] CreateInstances()
array[i] = GetInstance(i);
array[i] = CreateInstance(i);
/// <summary>
/// Returns a uniformly random sampled asset from this AssetSource
/// </summary>
/// <returns>The randomly sampled asset</returns>
return assetSourceLocation.GetAsset<T>((int)(m_Sampler.Sample() * Count));
return assetSourceLocation.LoadAsset<T>((int)(m_Sampler.Sample() * Count));
/// <summary>
/// Instantiates a uniformly random sampled asset from this AssetSource
/// </summary>
/// <returns>The generated random instance</returns>
public T SampleInstance()
{
CheckIfInitialized();

/// <summary>
/// Unloads all assets that have been loaded from this AssetSource
/// </summary>
public void ReleaseAssets()
{
CheckIfInitialized();

void CheckIfInitialized()
{
if (!m_Initialized)
throw new InvalidOperationException(
"Initialize() must be called on this AssetSource before executing this operation");
Initialize();
}
T CreateInstance(T asset)

22
com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/AssetSourceLocation.cs


namespace UnityEngine.Perception.Randomization
{
/// <summary>
/// Derive this class to load Unity assets from a specific location
/// </summary>
/// <summary>
/// The number of assets available at this location
/// </summary>
/// <summary>
/// Execute setup steps before accessing assets at this location
/// </summary>
/// <param name="archetype">The archetype that will be used to preprocess assets from this location</param>
/// <typeparam name="T">The type of assets that will be loaded from this location</typeparam>
/// <summary>
/// Unload all assets loaded from this location
/// </summary>
public abstract T GetAsset<T>(int index) where T : Object;
/// <summary>
/// Retrieves an asset from this location using the provided index
/// </summary>
/// <param name="index">The index to load the asset from</param>
/// <typeparam name="T">The type of asset to load</typeparam>
/// <returns>The loaded asset</returns>
public abstract T LoadAsset<T>(int index) where T : Object;
}
}

12
com.unity.perception/Runtime/Randomization/Randomizers/AssetSources/LocalAssetSourceLocation.cs


namespace UnityEngine.Perception.Randomization
{
/// <summary>
/// A basic <see cref="AssetSourceLocation"/> for loading local project assets
/// </summary>
/// <summary>
/// The list of local assets available from this source
/// </summary>
/// <inheritdoc/>
/// <inheritdoc/>
/// <inheritdoc/>
public override T GetAsset<T>(int index)
/// <inheritdoc/>
public override T LoadAsset<T>(int index)
{
return (T)assets[index];
}
正在加载...
取消
保存