-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!114 &11400000 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 0} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3} | ||
m_Name: ArrayPlus | ||
m_EditorClassIdentifier: | ||
serializedUdonProgramAsset: {fileID: 11400000, guid: a75b9eeddf6032e4685b370711a04f9f, type: 2} | ||
udonAssembly: | ||
assemblyError: | ||
sourceCsScript: {fileID: 11500000, guid: aacc8464b2231b94d9c536c46f11daf1, type: 3} | ||
scriptVersion: 2 | ||
compiledVersion: 2 | ||
behaviourSyncMode: 0 | ||
hasInteractEvent: 0 | ||
scriptID: 6835145117252330042 | ||
serializationData: | ||
SerializedFormat: 2 | ||
SerializedBytes: | ||
ReferencedUnityObjects: [] | ||
SerializedBytesString: | ||
Prefab: {fileID: 0} | ||
PrefabModificationsReferencedUnityObjects: [] | ||
PrefabModifications: [] | ||
SerializationNodes: | ||
- Name: fieldDefinitions | ||
Entry: 7 | ||
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition, | ||
UdonSharp.Editor]], mscorlib | ||
- Name: comparer | ||
Entry: 7 | ||
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String, | ||
mscorlib]], mscorlib | ||
- Name: | ||
Entry: 8 | ||
Data: | ||
- Name: | ||
Entry: 12 | ||
Data: 0 | ||
- Name: | ||
Entry: 13 | ||
Data: | ||
- Name: | ||
Entry: 8 | ||
Data: |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
| ||
using System; | ||
using UdonSharp; | ||
using UnityEngine; | ||
using VRC.SDKBase; | ||
using VRC.Udon; | ||
|
||
namespace UdonLab | ||
{ | ||
public class ArrayPlus : UdonSharpBehaviour | ||
{ | ||
public static T[] Add<T>(ref T[] _array, T _value, bool duplicates = true) | ||
{ | ||
if (!duplicates) | ||
{ | ||
int _index = Index(_array, _value); | ||
if (_index != -1) | ||
return _array; | ||
} | ||
T[] _newArray = new T[_array.Length + 1]; | ||
Array.Copy(_array, _newArray, _array.Length); | ||
_newArray[_array.Length] = _value; | ||
_array = _newArray; | ||
return _array; | ||
} | ||
public static T[] AddIndex<T>(ref T[] _array, T _value, int index, bool duplicates = true) | ||
{ | ||
if (!duplicates) | ||
{ | ||
int _index = Index(_array, _value); | ||
if (_index != -1) | ||
return _array; | ||
} | ||
if (index < 0 || index > _array.Length) | ||
{ | ||
return _array; | ||
} | ||
else if (index == _array.Length) | ||
{ | ||
return Add(ref _array, _value); | ||
} | ||
else | ||
{ | ||
T[] _newArray = new T[_array.Length + 1]; | ||
for (int i = 0; i < index; i++) | ||
{ | ||
_newArray[i] = _array[i]; | ||
} | ||
_newArray[index] = _value; | ||
for (int i = index + 1; i < _array.Length + 1; i++) | ||
{ | ||
_newArray[i] = _array[i - 1]; | ||
} | ||
return _newArray; | ||
} | ||
} | ||
public static int Find<T>(T[] _array, T _value) | ||
{ | ||
return Index(_array, _value); | ||
} | ||
public static int[] FindAll<T>(T[] _array, T _value) | ||
{ | ||
int[] _index = new int[0]; | ||
for (int i = 0; i < _array.Length; i++) | ||
{ | ||
if (_array[i].Equals(_value)) | ||
{ | ||
Add(ref _index, i); | ||
} | ||
} | ||
return _index; | ||
} | ||
public static T[] FindAllValue<T>(T[] _array, T _value) | ||
{ | ||
T[] _newArray = new T[0]; | ||
for (int i = 0; i < _array.Length; i++) | ||
{ | ||
if (_array[i].Equals(_value)) | ||
{ | ||
Add(ref _newArray, _array[i]); | ||
} | ||
} | ||
return _newArray; | ||
} | ||
public static int Index<T>(T[] _array, T _value) | ||
{ | ||
for (int i = 0; i < _array.Length; i++) | ||
{ | ||
if (_array[i].Equals(_value)) | ||
return i; | ||
} | ||
return -1; | ||
} | ||
public static T[] RemoveIndex<T>(ref T[] _array, int index) | ||
{ | ||
if (index < 0 || index >= _array.Length) | ||
{ | ||
return _array; | ||
} | ||
else | ||
{ | ||
T[] _newArray = new T[_array.Length - 1]; | ||
for (int i = 0; i < index; i++) | ||
{ | ||
_newArray[i] = _array[i]; | ||
} | ||
for (int i = index; i < _array.Length - 1; i++) | ||
{ | ||
_newArray[i] = _array[i + 1]; | ||
} | ||
_array = _newArray; | ||
return _array; | ||
} | ||
} | ||
public static T[] Remove<T>(ref T[] _array, T _value) | ||
{ | ||
int index = Index(_array, _value); | ||
if (index == -1) | ||
return _array; | ||
return RemoveIndex(ref _array, index); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.