Skip to content

Commit

Permalink
Merge pull request #136 from brunomikoski/feature/item-indices
Browse files Browse the repository at this point in the history
Feature/item indices
  • Loading branch information
brunomikoski committed Jan 12, 2024
2 parents 1bbaad8 + 0e49ca9 commit e7edb4d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Scripts/Runtime/Core/ScriptableObjectCollectionItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ public ScriptableObjectCollection Collection
return cachedCollection;
}
}

[NonSerialized] private bool didCacheIndex;
[NonSerialized] private int cachedIndex;
public int Index
{
get
{
if (!didCacheIndex)
{
didCacheIndex = true;
cachedIndex = Collection.Items.IndexOf(this);
}
return cachedIndex;
}
}

public void SetCollection(ScriptableObjectCollection collection)
{
Expand Down

0 comments on commit e7edb4d

Please sign in to comment.