/// <summary> /// Clones will call this constructor, grabbing the duration /// </summary> /// <param name="creator"></param> /// <param name="duration"></param> internal unsafe HapticHandle(CommandWithHandle creator, float duration) { init(creator); Debug.Assert(_handle != null); _duration = duration; }
internal unsafe void init(CommandWithHandle creator) { Debug.Assert(creator != null); _creator = creator; fixed(HLVR_Effect **effect_ptr = &_handle) { if (Interop.FAIL(Interop.HLVR_Effect_Create(effect_ptr))) { Debug.LogError("[HLVR] Failed to create new Haptic Handle!"); } } //Debug.Log("Inside init. Is creator null?!" + (creator == null)); _creator(_handle); }
/// <summary> /// If we want to construct the handle for the very first time, we have no duration info present. /// So we end up calculating it in the constructor, then caching it. Subsequent Clones() will copy the duration /// /// </summary> /// <param name="creator"></param> internal HapticHandle(CommandWithHandle creator) { init(creator); Interop.HLVR_EffectInfo info = new Interop.HLVR_EffectInfo(); //Failure by default int result = -1; unsafe { result = Interop.HLVR_Effect_GetInfo(_handle, ref info); } if (Interop.OK(result)) { _duration = info.Duration; } else { Debug.LogError(string.Format("Failed to fetch information about haptic handle; the handle has been disposed and is no longer usable.\n")); } }