public static object ConvertArrayOrList(WrappedVariable wrappedVariable, Type type) { // TODO: Investigate if this array copying could be simplified IList sourceList = (IList)wrappedVariable.Value; int count = sourceList.Count; if (type.IsArray) { // Copying to an array object newArray = Activator.CreateInstance(type, new object[] { count }); for (int i = 0; i < count; i++) { ((Array)newArray).SetValue(GetValue(wrappedVariable, sourceList[i]), i); } return(newArray); } else { object newList = Activator.CreateInstance(type, new object[] { 0 }); for (int i = 0; i < count; i++) { ((IList)newList).Add(GetValue(wrappedVariable, sourceList[i])); } return(newList); } }
public void OnObjectPickerChanged(Guid componentInstanceGuid, WrappedVariable variable, UnityObjectDescription objectDescription) { Debug.Log("OnObjectPickerChanged"); variable.Value = (objectDescription != null) ? objectDescription.Guid : Guid.Empty; commonContext.APIManager.SendToPlayers(new SetVariableRequest(componentInstanceGuid, variable)); //SendToPlayers(APIRequest.GetUnityObjects, componentDescription, variable.TypeFullName, variable.AssemblyName); }
static object GetValue(WrappedVariable wrappedVariable, object value) { if (wrappedVariable.DataType == DataType.UnityObjectReference && value is Guid) { return(ObjectMap.GetObjectFromGUID((Guid)value)); } else { return(value); } }
public void OnObjectPickerChanged(ObjectPickerContext context, WrappedVariable variable, UnityObjectDescription objectDescription) { if (context.ComponentGuid != Guid.Empty) { // Remote component GUID specified, send a SetVariableRequest to update a field or property variable.Value = (objectDescription != null) ? objectDescription.Guid : Guid.Empty; APIManager.SendToPlayers(new SetVariableRequest(context.ComponentGuid, variable)); } else if (context.ArgumentIndex != -1) { // If an argument index is supplied, this is updating an editor driven method argument set arguments[context.ArgumentIndex].Value = (objectDescription != null) ? objectDescription.Guid : Guid.Empty; } else { throw new NotImplementedException(); } }
public static void Show(ObjectPickerContext context, UnityObjectDescription[] objectDescriptions, WrappedVariable variable, ValueChangedCallback onValueChanged) { RemoteObjectPickerWindow window = EditorWindow.GetWindow <RemoteObjectPickerWindow>(true); window.context = context; window.objectDescriptions = objectDescriptions; window.variable = variable; window.onValueChanged = onValueChanged; if (variable != null) { window.index = objectDescriptions.Select(item => item.Guid).ToList().IndexOf((Guid)variable.Value) + 1; } window.titleContent = new GUIContent("Select Object"); window.ShowUtility(); }
public void OnOpenObjectPicker(ObjectPickerContext context, WrappedVariable variable) { APIManager.SendToPlayers(new GetUnityObjectsRequest(variable, context)); }
public void OnOpenObjectPicker(Guid componentInstanceGuid, WrappedVariable variable) { commonContext.APIManager.SendToPlayers(new GetUnityObjectsRequest(variable, componentInstanceGuid)); }