private void EditArray(Type elementType) { // Update Values when 'Save' is clicked if (_inspector != null) { // Update Values SetNewValue(_inspector.GetValues()); // Remove Inspector _inspector.RemoveFromHierarchy(); _inspector = null; // Update Button Text _editArrayButton.text = "Edit"; return; } // Otherwise set up the inspector _editArrayButton.text = "Save"; // Get value object, null is ok TryGetValueObject(out object value); // Create it new Type typedArrayInspector = (typeof(UdonArrayInspector <>)).MakeGenericType(elementType); _inspector = (Activator.CreateInstance(typedArrayInspector, value) as IArrayProvider); parent.Add(_inspector as VisualElement); }
private static WKSPointZ[] GetWksPointArray(int pointCount) { // TODO: Consider conditional compilation if > .NET 3.5... if (WksPointArrayProvider == null) { WksPointArrayProvider = new ArrayProvider <WKSPointZ>(); } return(WksPointArrayProvider.GetArray(pointCount)); }
public static TSource[] ToArray <TSource>(this IEnumerable <TSource> source) { if (source == null) { throw Error.ArgumentNull("source"); } IArrayProvider <TSource> arrayProvider = source as IArrayProvider <TSource>; return(arrayProvider != null?arrayProvider.ToArray() : EnumerableHelpers.ToArray(source)); }
internal Buffer(IEnumerable <TElement> source) { IArrayProvider <TElement> iterator = source as IArrayProvider <TElement>; if (iterator != null) { TElement[] array = iterator.ToArray(); items = array; count = array.Length; } else { items = EnumerableHelpers.ToArray(source, out count); } }
private void EditArray() { if (_inspector == null) { // Create it new Type typedArrayInspector = (typeof(UdonArrayInspector <>)).MakeGenericType(_type); _inspector = (Activator.CreateInstance(typedArrayInspector, null, _value) as IArrayProvider); AddInspector(); _inspectorOpen = true; _editArrayButton.text = "Save"; return; } else { // Update Values when 'Save' is clicked if (_inspectorOpen) { // Update Values var values = _inspector.GetValues(); _setValueCallback(values); // Remove Inspector _inspector.RemoveFromHierarchy(); // Update Button Text _editArrayButton.text = "Edit"; _inspectorOpen = false; return; } else { // Inspector exists, it's just removed _inspectorOpen = true; AddInspector(); _editArrayButton.text = "Save"; } } }