public UserProperty(USER_PROPERTY property) : this() { Name = property.name; Type = (UserPropertyType)property.type; switch (Type) { case UserPropertyType.Integer: _value.IntValue = property.intvalue; break; case UserPropertyType.Single: _value.FloatValue = property.floatvalue; break; case UserPropertyType.Boolean: _value.BoolValue = property.boolvalue; break; case UserPropertyType.String: _stringValue = property.stringvalue; break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Get all important information of EventInstance /// </summary> /// <param name="eventInstance">current EvnentInstance</param> private void GetEventInfo(EventInstance eventInstance) { ///Create EventDescription EventDescription eventDescription = new EventDescription(); eventInstance.getDescription(out eventDescription); ///Get min and max distance eventDescription.getMaximumDistance(out m_maxDistance); eventDescription.getMinimumDistance(out m_minumDistance); ///Get number of instance enabled eventDescription.getInstanceCount(out m_instanceCount); ///Check if has cue eventDescription.hasCue(out m_hasCue); eventInstance.getVolume(out m_volume, out m_maxVolume); ///Get all userPropery int _count; eventDescription.getUserPropertyCount(out _count); USER_PROPERTY[] userProperty = new USER_PROPERTY[_count]; m_userProperty = new string[_count]; for (int i = 0; i < _count; i++) { eventDescription.getUserPropertyByIndex(i, out userProperty[i]); m_userProperty[i] = userProperty[i].name + " | " + userProperty[i].stringValue(); } ///Check if is 3D or 2D bool _is3D = false; eventDescription.is3D(out _is3D); if (_is3D) { m_soundType = SoundType.is3D; } else { m_soundType = SoundType.is2D; } }
public RESULT getUserProperty(string name, out USER_PROPERTY property) { USER_PROPERTY_INTERNAL propertyInternal; RESULT result = FMOD_Studio_EventDescription_GetUserProperty( rawPtr, Encoding.UTF8.GetBytes(name + Char.MinValue), out propertyInternal); if (result != RESULT.OK) { property = new USER_PROPERTY(); return result; } property = propertyInternal.createPublic(); return RESULT.OK; }
public RESULT getUserPropertyByIndex(int index, out USER_PROPERTY property) { USER_PROPERTY_INTERNAL propertyInternal; RESULT result = FMOD_Studio_EventDescription_GetUserPropertyByIndex(rawPtr, index, out propertyInternal); if (result != RESULT.OK) { property = new USER_PROPERTY(); return result; } property = propertyInternal.createPublic(); return RESULT.OK; }
// Helper functions public USER_PROPERTY createPublic() { USER_PROPERTY publicProperty = new USER_PROPERTY(); publicProperty.name = MarshallingHelper.stringFromNativeUtf8(name); publicProperty.type = type; switch (type) { case USER_PROPERTY_TYPE.INTEGER: publicProperty.intValue = value.intValue; break; case USER_PROPERTY_TYPE.BOOLEAN: publicProperty.boolValue = value.boolValue; break; case USER_PROPERTY_TYPE.FLOAT: publicProperty.floatValue = value.floatValue; break; case USER_PROPERTY_TYPE.STRING: publicProperty.stringValue = MarshallingHelper.stringFromNativeUtf8(value.stringValue); break; } return publicProperty; }