文档

Unity Engine

Unity Engine

Add(T)

Adds a new item. If the item is already present in the collection, this method should throw, but currently does not! Instead, it returns false without replacing said item.
阅读时间1 分钟最后更新于 1 个月前

Definition

  • Type: Method
  • Namespace: Unity.Collections
  • Assembly: UnityEngine.ManagedKernelModule
public bool Add(T item)

Parameters

item

T
The value to add.

Returns

Type

Description

boolTrue if the value was not already present.

Remarks

Prefer NativeParallelHashSet<T>.TryAdd if your intent is to allow graceful failure, as this API will eventually become more strict (and begin to throw).