/// <summary> /// whether or not the hair touch modifier is currently pressed /// if so, pressing a key on the keyboard will only emit touch and hair touch events, /// but not a real press. /// </summary> /// <returns>whether or not the HairTouchModifier is active</returns> protected virtual bool IsHairTouchModifierPressed() { return(Input.GetKey(VRTK_SharedMethods.GetDictionaryValue(keyMappings, "HairTouchModifier", KeyCode.None))); }
/// <summary> /// The IsTouchpadStatic method is used to determine if the touchpad is currently not being moved. /// </summary> /// <param name="currentAxisValues"></param> /// <param name="previousAxisValues"></param> /// <param name="compareFidelity"></param> /// <returns>Returns true if the touchpad is not currently being touched or moved.</returns> public override bool IsTouchpadStatic(bool isTouched, Vector2 currentAxisValues, Vector2 previousAxisValues, int compareFidelity) { return(!isTouched || VRTK_SharedMethods.Vector2ShallowCompare(currentAxisValues, previousAxisValues, compareFidelity)); }
/// <summary> /// The GetPointerLength method retrieves the maximum UI Pointer length for the given pointer ID. /// </summary> /// <param name="pointerId">The pointer ID for the UI Pointer to recieve the length for.</param> /// <returns>The maximum length the UI Pointer will cast to.</returns> public static float GetPointerLength(int pointerId) { return(VRTK_SharedMethods.GetDictionaryValue(pointerLengths, pointerId, float.MaxValue)); }
protected virtual string GeneratePlayAreaCursorName() { return(VRTK_SharedMethods.GenerateVRTKObjectName(true, gameObject.name, "PlayAreaCursor")); }
protected virtual void CheckFalling() { if (isFalling && VRTK_SharedMethods.RoundFloat(lastPlayAreaPosition.y, fallCheckPrecision) == VRTK_SharedMethods.RoundFloat(playArea.position.y, fallCheckPrecision)) { StopFall(); } }
protected override bool DetectSetup() { finalDirection = (direction == Direction.autodetect ? DetectDirection() : direction); if (finalDirection == Direction.autodetect) { return(false); } // determin sub-direction depending on handle Bounds handleBounds = VRTK_SharedMethods.GetBounds(GetHandle().transform, transform); Bounds bodyBounds = VRTK_SharedMethods.GetBounds(GetBody().transform, transform); switch (finalDirection) { case Direction.x: subDirection = (handleBounds.center.x > bodyBounds.center.x) ? -1 : 1; pullDistance = bodyBounds.extents.x; break; case Direction.y: subDirection = (handleBounds.center.y > bodyBounds.center.y) ? -1 : 1; pullDistance = bodyBounds.extents.y; break; case Direction.z: subDirection = (handleBounds.center.z > bodyBounds.center.z) ? -1 : 1; pullDistance = bodyBounds.extents.z; break; } if (body & handle) { // handle should be outside body hierarchy, otherwise anchor-by-bounds calculation is off if (handle.transform.IsChildOf(body.transform)) { return(false); } } if (drawerJointCreated) { drawerJoint.xMotion = ConfigurableJointMotion.Locked; drawerJoint.yMotion = ConfigurableJointMotion.Locked; drawerJoint.zMotion = ConfigurableJointMotion.Locked; switch (finalDirection) { case Direction.x: drawerJoint.axis = Vector3.right; drawerJoint.xMotion = ConfigurableJointMotion.Limited; break; case Direction.y: drawerJoint.axis = Vector3.up; drawerJoint.yMotion = ConfigurableJointMotion.Limited; break; case Direction.z: drawerJoint.axis = Vector3.forward; drawerJoint.zMotion = ConfigurableJointMotion.Limited; break; } drawerJoint.anchor = drawerJoint.axis * (-subDirection * pullDistance); } if (drawerJoint) { drawerJoint.angularXMotion = ConfigurableJointMotion.Locked; drawerJoint.angularYMotion = ConfigurableJointMotion.Locked; drawerJoint.angularZMotion = ConfigurableJointMotion.Locked; pullDistance *= (maxExtend * 1.8f); // don't let it pull out completely SoftJointLimit drawerJointLimit = drawerJoint.linearLimit; drawerJointLimit.limit = pullDistance; drawerJoint.linearLimit = drawerJointLimit; if (connectedTo) { drawerJoint.connectedBody = connectedTo.GetComponent <Rigidbody>(); } } if (drawerSnapForceCreated) { drawerSnapForce.force = GetThirdDirection(drawerJoint.axis, drawerJoint.secondaryAxis) * (subDirection * -50f); } return(true); }
public virtual void TriggerHapticPulse(float strength) { VRTK_SharedMethods.TriggerHapticPulse(VRTK_DeviceFinder.GetControllerIndex(gameObject), strength); }
private void RefreshData() { stringBuilder.Length = 0; Assembly editorAssembly = typeof(VRTK_SDKManagerEditor).Assembly; Assembly assembly = typeof(VRTK_SDKManager).Assembly; Append( "Versions", () => { Append("Unity", InternalEditorUtility.GetFullUnityVersion()); Append("VRTK", VRTK_Defines.CurrentVersion + " (may not be correct if source is GitHub)"); Type steamVRUpdateType = editorAssembly.GetType("SteamVR_Update"); if (steamVRUpdateType != null) { FieldInfo currentVersionField = steamVRUpdateType.GetField("currentVersion", BindingFlags.NonPublic | BindingFlags.Static); if (currentVersionField != null) { string currentVersion = (string)currentVersionField.GetValue(null); Append("SteamVR", currentVersion); } } Type ovrPluginType = assembly.GetType("OVRPlugin"); if (ovrPluginType != null) { Append( "OVRPlugin (Oculus Utilities)", () => { FieldInfo wrapperVersionField = ovrPluginType.GetField("wrapperVersion", BindingFlags.Public | BindingFlags.Static); if (wrapperVersionField != null) { Version wrapperVersion = (Version)wrapperVersionField.GetValue(null); Append("wrapperVersion", wrapperVersion); } PropertyInfo versionField = ovrPluginType.GetProperty("version", BindingFlags.Public | BindingFlags.Static); if (versionField != null) { Version version = (Version)versionField.GetGetMethod().Invoke(null, null); Append("version", version); } PropertyInfo nativeSDKVersionField = ovrPluginType.GetProperty("nativeSDKVersion", BindingFlags.Public | BindingFlags.Static); if (nativeSDKVersionField != null) { Version nativeSDKVersion = (Version)nativeSDKVersionField.GetGetMethod().Invoke(null, null); Append("nativeSDKVersion", nativeSDKVersion); } } ); } } ); Append( "VR Settings", () => { foreach (BuildTargetGroup targetGroup in VRTK_SharedMethods.GetValidBuildTargetGroups()) { bool isVREnabled; #if UNITY_5_5_OR_NEWER isVREnabled = VREditor.GetVREnabledOnTargetGroup(targetGroup); #else isVREnabled = VREditor.GetVREnabled(targetGroup); #endif if (!isVREnabled) { continue; } string[] vrEnabledDevices; #if UNITY_5_5_OR_NEWER vrEnabledDevices = VREditor.GetVREnabledDevicesOnTargetGroup(targetGroup); #else vrEnabledDevices = VREditor.GetVREnabledDevices(targetGroup); #endif Append(targetGroup, string.Join(", ", vrEnabledDevices)); } } ); Append( "Scripting Define Symbols", () => { foreach (BuildTargetGroup targetGroup in VRTK_SharedMethods.GetValidBuildTargetGroups()) { string symbols = string.Join( ";", PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup) .Split(';') .Where(symbol => !symbol.StartsWith(VRTK_Defines.VersionScriptingDefineSymbolPrefix, StringComparison.Ordinal)) .ToArray()); if (!string.IsNullOrEmpty(symbols)) { Append(targetGroup, symbols); } } } ); stringBuilder.Length--; }
protected override bool DetectSetup() { // detect axis doorHinge = GetDoor().GetComponent <HingeJoint>(); if (doorHinge && !doorHingeCreated) { direction = Direction.autodetect; } finalDirection = (direction == Direction.autodetect) ? DetectDirection() : direction; if (finalDirection == Direction.autodetect) { return(false); } if (doorHinge && !doorHingeCreated) { // if there is a hinge joint already it overrides axis selection direction = finalDirection; } // detect opening direction Bounds doorBounds = VRTK_SharedMethods.GetBounds(GetDoor().transform, transform); if (doorHinge == null || doorHingeCreated) { if (handles) { // determin sub-direction depending on handle location Bounds handleBounds = VRTK_SharedMethods.GetBounds(handles.transform, transform); switch (finalDirection) { case Direction.x: if ((handleBounds.center.z + handleBounds.extents.z) > (doorBounds.center.z + doorBounds.extents.z) || (handleBounds.center.z - handleBounds.extents.z) < (doorBounds.center.z - doorBounds.extents.z)) { subDirection = (handleBounds.center.y > doorBounds.center.y) ? -1 : 1; secondaryDirection = Vector3.up; } else { subDirection = (handleBounds.center.z > doorBounds.center.z) ? -1 : 1; secondaryDirection = Vector3.forward; } break; case Direction.y: if ((handleBounds.center.z + handleBounds.extents.z) > (doorBounds.center.z + doorBounds.extents.z) || (handleBounds.center.z - handleBounds.extents.z) < (doorBounds.center.z - doorBounds.extents.z)) { subDirection = (handleBounds.center.x > doorBounds.center.x) ? -1 : 1; secondaryDirection = Vector3.right; } else { subDirection = (handleBounds.center.z > doorBounds.center.z) ? -1 : 1; secondaryDirection = Vector3.forward; } break; case Direction.z: if ((handleBounds.center.x + handleBounds.extents.x) > (doorBounds.center.x + doorBounds.extents.x) || (handleBounds.center.x - handleBounds.extents.x) < (doorBounds.center.x - doorBounds.extents.x)) { subDirection = (handleBounds.center.y > doorBounds.center.y) ? -1 : 1; secondaryDirection = Vector3.up; } else { subDirection = (handleBounds.center.x > doorBounds.center.x) ? -1 : 1; secondaryDirection = Vector3.right; } break; } } else { switch (finalDirection) { case Direction.x: secondaryDirection = (doorBounds.extents.y > doorBounds.extents.z) ? Vector3.up : Vector3.forward; break; case Direction.y: secondaryDirection = (doorBounds.extents.x > doorBounds.extents.z) ? Vector3.right : Vector3.forward; break; case Direction.z: secondaryDirection = (doorBounds.extents.y > doorBounds.extents.x) ? Vector3.up : Vector3.right; break; } // TODO: derive how to detect -1 subDirection = 1; } } else { // calculate directions from existing anchor Vector3 existingAnchorDirection = doorBounds.center - doorHinge.connectedAnchor; if (existingAnchorDirection.x != 0) { secondaryDirection = Vector3.right; subDirection = existingAnchorDirection.x <= 0 ? 1 : -1; } else if (existingAnchorDirection.y != 0) { secondaryDirection = Vector3.up; subDirection = existingAnchorDirection.y <= 0 ? 1 : -1; } else if (existingAnchorDirection.z != 0) { secondaryDirection = Vector3.forward; subDirection = existingAnchorDirection.z <= 0 ? 1 : -1; } } if (doorHingeCreated) { float extents = 0; if (secondaryDirection == Vector3.right) { extents = doorBounds.extents.x / GetDoor().transform.lossyScale.x; } else if (secondaryDirection == Vector3.up) { extents = doorBounds.extents.y / GetDoor().transform.lossyScale.y; } else { extents = doorBounds.extents.z / GetDoor().transform.lossyScale.z; } doorHinge.anchor = secondaryDirection * subDirection * extents; doorHinge.axis = Direction2Axis(finalDirection); } if (doorHinge) { doorHinge.useLimits = true; doorHinge.enableCollision = true; JointLimits limits = doorHinge.limits; limits.min = openInward ? -maxAngle : 0; limits.max = openOutward ? maxAngle : 0; limits.bounciness = 0; doorHinge.limits = limits; } if (doorSnapForceCreated) { doorSnapForce.relativeForce = GetThirdDirection(doorHinge.axis, secondaryDirection) * (subDirection * (-5f * subDirection)); } return(true); }
protected override void OnDrawGizmos() { base.OnDrawGizmos(); if (!enabled || !setupSuccessful) { return; } // show opening direction Bounds handleBounds = new Bounds(); Bounds doorBounds = VRTK_SharedMethods.GetBounds(GetDoor().transform, GetDoor().transform); float extensionLength = 0.5f; if (handles) { handleBounds = VRTK_SharedMethods.GetBounds(handles.transform, handles.transform); } Vector3 firstDirection = Vector3.zero; Vector3 secondDirection = Vector3.zero; Vector3 thirdDirection = GetThirdDirection(Direction2Axis(finalDirection), secondaryDirection); bool invertGizmos = false; switch (finalDirection) { case Direction.x: if (thirdDirection == Vector3.up) { firstDirection = transform.up.normalized; secondDirection = transform.forward.normalized; extensionLength *= doorBounds.extents.z; } else { firstDirection = transform.forward.normalized; secondDirection = transform.up.normalized; extensionLength *= doorBounds.extents.y; invertGizmos = true; } break; case Direction.y: if (thirdDirection == Vector3.right) { firstDirection = transform.right.normalized; secondDirection = transform.forward.normalized; extensionLength *= doorBounds.extents.z; invertGizmos = true; } else { firstDirection = transform.forward.normalized; secondDirection = transform.right.normalized; extensionLength *= doorBounds.extents.x; } break; case Direction.z: if (thirdDirection == Vector3.up) { firstDirection = transform.up.normalized; secondDirection = transform.right.normalized; extensionLength *= doorBounds.extents.x; invertGizmos = true; } else { firstDirection = transform.right.normalized; secondDirection = transform.up.normalized; extensionLength *= doorBounds.extents.y; } break; } if ((!invertGizmos && openInward) || (invertGizmos && openOutward)) { Vector3 point1Start = (handles) ? handleBounds.center : doorBounds.center; Vector3 point1End = point1Start + secondDirection * extensionLength * subDirection - firstDirection * (extensionLength / 2f) * subDirection; Gizmos.DrawLine(point1Start, point1End); Gizmos.DrawSphere(point1End, extensionLength / 8f); } if ((!invertGizmos && openOutward) || (invertGizmos && openInward)) { Vector3 point2Start = (handles) ? handleBounds.center : doorBounds.center; Vector3 point2End = point2Start + secondDirection * extensionLength * subDirection + firstDirection * (extensionLength / 2f) * subDirection; Gizmos.DrawLine(point2Start, point2End); Gizmos.DrawSphere(point2End, extensionLength / 8f); } }
protected override void OnDrawGizmos() { base.OnDrawGizmos(); if (!enabled || !setupSuccessful) { return; } // show opening direction Bounds handleBounds = new Bounds(); Bounds doorBounds = VRTK_SharedMethods.GetBounds(getDoor().transform, getDoor().transform); float length = 0.5f; if (handles) { handleBounds = VRTK_SharedMethods.GetBounds(handles.transform, handles.transform); } Vector3 dir = Vector3.zero; Vector3 dir2 = Vector3.zero; Vector3 thirdDirection = getThirdDirection(Direction2Axis(finalDirection), secondaryDirection); bool invertGizmos = false; switch (finalDirection) { case Direction.x: if (thirdDirection == Vector3.up) { dir = transform.up.normalized; dir2 = transform.forward.normalized; length *= doorBounds.extents.z; } else { dir = transform.forward.normalized; dir2 = transform.up.normalized; length *= doorBounds.extents.y; invertGizmos = true; } break; case Direction.y: if (thirdDirection == Vector3.right) { dir = transform.right.normalized; dir2 = transform.forward.normalized; length *= doorBounds.extents.z; invertGizmos = true; } else { dir = transform.forward.normalized; dir2 = transform.right.normalized; length *= doorBounds.extents.x; } break; case Direction.z: if (thirdDirection == Vector3.up) { dir = transform.up.normalized; dir2 = transform.right.normalized; length *= doorBounds.extents.x; invertGizmos = true; } else { dir = transform.right.normalized; dir2 = transform.up.normalized; length *= doorBounds.extents.y; } break; } if ((!invertGizmos && openInward) || (invertGizmos && openOutward)) { Vector3 p1 = (handles) ? handleBounds.center : doorBounds.center; Vector3 p1end = p1 + dir2 * length * subDirection - dir * (length / 2f) * subDirection; Gizmos.DrawLine(p1, p1end); Gizmos.DrawSphere(p1end, length / 8f); } if ((!invertGizmos && openOutward) || (invertGizmos && openInward)) { Vector3 p2 = (handles) ? handleBounds.center : doorBounds.center; Vector3 p2end = p2 + dir2 * length * subDirection + dir * (length / 2f) * subDirection; Gizmos.DrawLine(p2, p2end); Gizmos.DrawSphere(p2end, length / 8f); } }
// Token: 0x060013DB RID: 5083 RVA: 0x0006D228 File Offset: 0x0006B428 protected virtual Vector3 CalculateActivationDir() { Bounds bounds = VRTK_SharedMethods.GetBounds(base.transform, base.transform, null); Vector3 a = Vector3.zero; float num = 0f; switch (this.direction) { case VRTK_Button.ButtonDirection.x: case VRTK_Button.ButtonDirection.negX: if (Mathf.RoundToInt(Mathf.Abs(base.transform.right.x)) == 1) { a = base.transform.right; num = bounds.extents.x; } else if (Mathf.RoundToInt(Mathf.Abs(base.transform.up.x)) == 1) { a = base.transform.up; num = bounds.extents.y; } else if (Mathf.RoundToInt(Mathf.Abs(base.transform.forward.x)) == 1) { a = base.transform.forward; num = bounds.extents.z; } a *= (float)((this.direction == VRTK_Button.ButtonDirection.x) ? -1 : 1); break; case VRTK_Button.ButtonDirection.y: case VRTK_Button.ButtonDirection.negY: if (Mathf.RoundToInt(Mathf.Abs(base.transform.right.y)) == 1) { a = base.transform.right; num = bounds.extents.x; } else if (Mathf.RoundToInt(Mathf.Abs(base.transform.up.y)) == 1) { a = base.transform.up; num = bounds.extents.y; } else if (Mathf.RoundToInt(Mathf.Abs(base.transform.forward.y)) == 1) { a = base.transform.forward; num = bounds.extents.z; } a *= (float)((this.direction == VRTK_Button.ButtonDirection.y) ? -1 : 1); break; case VRTK_Button.ButtonDirection.z: case VRTK_Button.ButtonDirection.negZ: if (Mathf.RoundToInt(Mathf.Abs(base.transform.right.z)) == 1) { a = base.transform.right; num = bounds.extents.x; } else if (Mathf.RoundToInt(Mathf.Abs(base.transform.up.z)) == 1) { a = base.transform.up; num = bounds.extents.y; } else if (Mathf.RoundToInt(Mathf.Abs(base.transform.forward.z)) == 1) { a = base.transform.forward; num = bounds.extents.z; } a *= (float)((this.direction == VRTK_Button.ButtonDirection.z) ? -1 : 1); break; } return(a * (num + this.activationDistance)); }
// Token: 0x060013DA RID: 5082 RVA: 0x0006CE60 File Offset: 0x0006B060 protected virtual VRTK_Button.ButtonDirection DetectDirection() { VRTK_Button.ButtonDirection buttonDirection = VRTK_Button.ButtonDirection.autodetect; Bounds bounds = VRTK_SharedMethods.GetBounds(base.transform, null, null); RaycastHit raycastHit; Physics.Raycast(bounds.center, Vector3.forward, out raycastHit, bounds.extents.z * 4f, -5, QueryTriggerInteraction.UseGlobal); RaycastHit raycastHit2; Physics.Raycast(bounds.center, Vector3.back, out raycastHit2, bounds.extents.z * 4f, -5, QueryTriggerInteraction.UseGlobal); RaycastHit raycastHit3; Physics.Raycast(bounds.center, Vector3.left, out raycastHit3, bounds.extents.x * 4f, -5, QueryTriggerInteraction.UseGlobal); RaycastHit raycastHit4; Physics.Raycast(bounds.center, Vector3.right, out raycastHit4, bounds.extents.x * 4f, -5, QueryTriggerInteraction.UseGlobal); RaycastHit raycastHit5; Physics.Raycast(bounds.center, Vector3.up, out raycastHit5, bounds.extents.y * 4f, -5, QueryTriggerInteraction.UseGlobal); RaycastHit raycastHit6; Physics.Raycast(bounds.center, Vector3.down, out raycastHit6, bounds.extents.y * 4f, -5, QueryTriggerInteraction.UseGlobal); float num = (raycastHit4.collider != null) ? raycastHit4.distance : float.MaxValue; float num2 = (raycastHit6.collider != null) ? raycastHit6.distance : float.MaxValue; float num3 = (raycastHit2.collider != null) ? raycastHit2.distance : float.MaxValue; float num4 = (raycastHit3.collider != null) ? raycastHit3.distance : float.MaxValue; float num5 = (raycastHit5.collider != null) ? raycastHit5.distance : float.MaxValue; float num6 = (raycastHit.collider != null) ? raycastHit.distance : float.MaxValue; float num7 = 0f; Vector3 a = Vector3.zero; if (VRTK_SharedMethods.IsLowest(num, new float[] { num2, num3, num4, num5, num6 })) { buttonDirection = VRTK_Button.ButtonDirection.negX; a = raycastHit4.point; num7 = bounds.extents.x; } else if (VRTK_SharedMethods.IsLowest(num2, new float[] { num, num3, num4, num5, num6 })) { buttonDirection = VRTK_Button.ButtonDirection.y; a = raycastHit6.point; num7 = bounds.extents.y; } else if (VRTK_SharedMethods.IsLowest(num3, new float[] { num, num2, num4, num5, num6 })) { buttonDirection = VRTK_Button.ButtonDirection.z; a = raycastHit2.point; num7 = bounds.extents.z; } else if (VRTK_SharedMethods.IsLowest(num4, new float[] { num, num2, num3, num5, num6 })) { buttonDirection = VRTK_Button.ButtonDirection.x; a = raycastHit3.point; num7 = bounds.extents.x; } else if (VRTK_SharedMethods.IsLowest(num5, new float[] { num, num2, num3, num4, num6 })) { buttonDirection = VRTK_Button.ButtonDirection.negY; a = raycastHit5.point; num7 = bounds.extents.y; } else if (VRTK_SharedMethods.IsLowest(num6, new float[] { num, num2, num3, num4, num5 })) { buttonDirection = VRTK_Button.ButtonDirection.negZ; a = raycastHit.point; num7 = bounds.extents.z; } this.activationDistance = (Vector3.Distance(a, bounds.center) - num7) * 0.95f; if (buttonDirection == VRTK_Button.ButtonDirection.autodetect || this.activationDistance < 0.001f) { buttonDirection = VRTK_Button.ButtonDirection.autodetect; this.activationDistance = 0f; } else { this.activationDir = a - bounds.center; } return(buttonDirection); }
protected virtual void Awake() { VRTK_PlayerObject.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.CameraRig); headset = VRTK_SharedMethods.AddCameraFade(); playArea = VRTK_DeviceFinder.PlayAreaTransform(); }
public virtual void TriggerHapticPulse(float strength, float duration, float pulseInterval) { VRTK_SharedMethods.TriggerHapticPulse(VRTK_DeviceFinder.GetControllerIndex(gameObject), strength, duration, pulseInterval); }
/// <summary> /// Manages (i.e. adds and removes) the scripting define symbols of the <see cref="PlayerSettings"/> for the currently set SDK infos. /// This method is only available in the editor, so usage of the method needs to be surrounded by `#if UNITY_EDITOR` and `#endif` when used /// in a type that is also compiled for a standalone build. /// </summary> /// <param name="ignoreAutoManageScriptDefines">Whether to ignore <see cref="autoManageScriptDefines"/> while deciding to manage.</param> /// <param name="ignoreIsActiveAndEnabled">Whether to ignore <see cref="Behaviour.isActiveAndEnabled"/> while deciding to manage.</param> /// <returns>Whether the <see cref="PlayerSettings"/>' scripting define symbols were changed.</returns> public bool ManageScriptingDefineSymbols(bool ignoreAutoManageScriptDefines, bool ignoreIsActiveAndEnabled) { if (!((ignoreAutoManageScriptDefines || autoManageScriptDefines) && (ignoreIsActiveAndEnabled || isActiveAndEnabled))) { return(false); } //get valid BuildTargetGroups BuildTargetGroup[] targetGroups = VRTK_SharedMethods.GetValidBuildTargetGroups(); Dictionary <BuildTargetGroup, HashSet <string> > newSymbolsByTargetGroup = new Dictionary <BuildTargetGroup, HashSet <string> >(targetGroups.Length); //get current non-removable scripting define symbols foreach (BuildTargetGroup targetGroup in targetGroups) { IEnumerable <string> nonSDKSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup) .Split(';') .Where(symbol => !symbol.StartsWith(SDK_ScriptingDefineSymbolPredicateAttribute.RemovableSymbolPrefix, StringComparison.Ordinal)); newSymbolsByTargetGroup[targetGroup] = new HashSet <string>(nonSDKSymbols); } VRTK_SDKInfo[] availableSDKInfos = AvailableSystemSDKInfos .Concat(AvailableBoundariesSDKInfos) .Concat(AvailableHeadsetSDKInfos) .Concat(AvailableControllerSDKInfos) .ToArray(); HashSet <SDK_DescriptionAttribute> descriptions = new HashSet <SDK_DescriptionAttribute>( availableSDKInfos.Select(info => info.description) .Where(description => !description.describesFallbackSDK) ); HashSet <string> activeSymbols = new HashSet <string>(activeScriptingDefineSymbolsWithoutSDKClasses.Select(attribute => attribute.symbol)); //get scripting define symbols and check whether the predicates allow us to add the symbols foreach (ScriptingDefineSymbolPredicateInfo predicateInfo in AvailableScriptingDefineSymbolPredicateInfos) { SDK_ScriptingDefineSymbolPredicateAttribute predicateAttribute = predicateInfo.attribute; string symbol = predicateAttribute.symbol; if (!activeSymbols.Contains(symbol) && !descriptions.Any(description => description.symbol == symbol && description.buildTargetGroup == predicateAttribute.buildTargetGroup)) { continue; } MethodInfo methodInfo = predicateInfo.methodInfo; if (!(bool)methodInfo.Invoke(null, null)) { continue; } //add symbols from all predicate attributes on the method since multiple ones are allowed SDK_ScriptingDefineSymbolPredicateAttribute[] allAttributes = (SDK_ScriptingDefineSymbolPredicateAttribute[])methodInfo.GetCustomAttributes(typeof(SDK_ScriptingDefineSymbolPredicateAttribute), false); foreach (SDK_ScriptingDefineSymbolPredicateAttribute attribute in allAttributes) { BuildTargetGroup buildTargetGroup = attribute.buildTargetGroup; HashSet <string> newSymbols; if (!newSymbolsByTargetGroup.TryGetValue(buildTargetGroup, out newSymbols)) { newSymbols = new HashSet <string>(); newSymbolsByTargetGroup[buildTargetGroup] = newSymbols; } newSymbols.Add(attribute.symbol); } } bool changedSymbols = false; //apply new set of scripting define symbols foreach (KeyValuePair <BuildTargetGroup, HashSet <string> > keyValuePair in newSymbolsByTargetGroup) { BuildTargetGroup targetGroup = keyValuePair.Key; string[] currentSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup) .Split(';') .Distinct() .OrderBy(symbol => symbol, StringComparer.Ordinal) .ToArray(); string[] newSymbols = keyValuePair.Value.OrderBy(symbol => symbol, StringComparer.Ordinal).ToArray(); if (currentSymbols.SequenceEqual(newSymbols)) { continue; } PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Join(";", newSymbols)); string[] removedSymbols = currentSymbols.Except(newSymbols).ToArray(); if (removedSymbols.Length > 0) { VRTK_Logger.Info(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SCRIPTING_DEFINE_SYMBOLS_REMOVED, targetGroup, string.Join(", ", removedSymbols))); } string[] addedSymbols = newSymbols.Except(currentSymbols).ToArray(); if (addedSymbols.Length > 0) { VRTK_Logger.Info(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SCRIPTING_DEFINE_SYMBOLS_ADDED, targetGroup, string.Join(", ", addedSymbols))); } if (!changedSymbols) { changedSymbols = removedSymbols.Length > 0 || addedSymbols.Length > 0; } } return(changedSymbols); }
protected virtual void ConfigureForCurrentSDKSetup() { if (headsetCameraCopy != null) { Destroy(headsetCameraCopy.gameObject); } headsetCameraTransformFollow.enabled = false; followScript.enabled = false; if (sdkManager.loadedSetup == null) { return; } Camera headsetCamera = VRTK_DeviceFinder.HeadsetCamera().GetComponent <Camera>(); desktopCamera.depth = headsetCamera.depth + 1; desktopCamera.stereoTargetEye = StereoTargetEyeMask.None; followScript.gameObjectToFollow = headsetCamera.gameObject; followScript.gameObjectToChange = desktopCamera.gameObject; followScript.Follow(); followScript.enabled = true; if (headsetImage == null) { return; } if (headsetRenderTexture == null) { headsetRenderTexture = new RenderTexture( (int)headsetImage.rectTransform.rect.width, (int)headsetImage.rectTransform.rect.height, 24, RenderTextureFormat.ARGB32) { name = VRTK_SharedMethods.GenerateVRTKObjectName(true, "Headset RenderTexture") }; } headsetCameraCopy = Instantiate(headsetCamera, transform); headsetCameraCopy.name = VRTK_SharedMethods.GenerateVRTKObjectName(true, "Headset Camera Copy"); headsetCameraCopy.targetTexture = headsetRenderTexture; foreach (Transform child in headsetCameraCopy.transform) { Destroy(child.gameObject); } IEnumerable <Component> componentsToDestroy = headsetCameraCopy .GetComponents <Component>() .Where(component => component != headsetCameraCopy && !(component is Transform)); foreach (Component component in componentsToDestroy) { Destroy(component); } headsetCameraTransformFollow.gameObjectToFollow = headsetCamera.gameObject; headsetCameraTransformFollow.gameObjectToChange = headsetCameraCopy.gameObject; headsetCameraTransformFollow.Follow(); headsetCameraTransformFollow.enabled = true; headsetImage.texture = headsetRenderTexture; headsetImage.SetNativeSize(); }