private void CreateHighlightModel() { if (customOutlineModel != null) { customOutlineModel = (customOutlineModel.GetComponent <Renderer>() ? customOutlineModel : customOutlineModel.GetComponentInChildren <Renderer>().gameObject); } else if (customOutlineModelPath != "") { var getChildModel = transform.FindChild(customOutlineModelPath); customOutlineModel = (getChildModel ? getChildModel.gameObject : null); } GameObject copyModel = customOutlineModel; if (copyModel == null) { copyModel = (GetComponent <Renderer>() ? gameObject : GetComponentInChildren <Renderer>().gameObject); } if (copyModel == null) { Debug.LogError("No Renderer has been found on the model to add highlighting to"); return; } highlightModel = new GameObject(name + "_HighlightModel"); highlightModel.transform.SetParent(copyModel.transform.parent, false); highlightModel.transform.localPosition = copyModel.transform.localPosition; highlightModel.transform.localRotation = copyModel.transform.localRotation; highlightModel.transform.localScale = copyModel.transform.localScale; highlightModel.transform.SetParent(transform); foreach (var component in copyModel.GetComponents <Component>()) { if (Array.IndexOf(copyComponents, component.GetType().ToString()) >= 0) { VRTK_SharedMethods.CloneComponent(component, highlightModel); } } var copyMesh = copyModel.GetComponent <MeshFilter>(); var highlightMesh = highlightModel.GetComponent <MeshFilter>(); if (highlightMesh) { highlightModel.GetComponent <MeshFilter>().mesh = copyMesh.mesh; highlightModel.GetComponent <Renderer>().material = stencilOutline; } highlightModel.SetActive(false); VRTK_PlayerObject.SetPlayerObject(highlightModel, VRTK_PlayerObject.ObjectTypes.Highlighter); }
private void CopyCustomJoint() { if (customJoint) { jointHolder = new GameObject(); jointHolder.transform.SetParent(transform); jointHolder.AddComponent <Rigidbody>().isKinematic = true; VRTK_SharedMethods.CloneComponent(customJoint, jointHolder, true); jointHolder.name = "JointHolder"; jointHolder.SetActive(false); Destroy(customJoint); customJoint = jointHolder.GetComponent <Joint>(); } }
protected virtual void CopyCustomJoint() { if (customJoint != null) { jointHolder = new GameObject(); jointHolder.transform.SetParent(transform); jointHolder.AddComponent <Rigidbody>().isKinematic = true; VRTK_SharedMethods.CloneComponent(customJoint, jointHolder, true); jointHolder.name = VRTK_SharedMethods.GenerateVRTKObjectName(true, "JointHolder"); jointHolder.SetActive(false); Destroy(customJoint); customJoint = jointHolder.GetComponent <Joint>(); } }
protected override void CreateJoint(GameObject obj) { if (!jointHolder) { Debug.LogError("The VRTK_CustomJointGrabAttach script requires a Joint component to be provided to the `Custom Joint` parameter."); return; } var storedJoint = jointHolder.GetComponent <Joint>(); var storeName = gameObject.name; VRTK_SharedMethods.CloneComponent(storedJoint, obj, true); gameObject.name = storeName; givenJoint = obj.GetComponent(storedJoint.GetType()) as Joint; base.CreateJoint(obj); }
protected override void CreateJoint(GameObject obj) { if (jointHolder == null) { VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_CustomJointGrabAttach", "Joint", "customJoint", "the same")); return; } Joint storedJoint = jointHolder.GetComponent <Joint>(); string storeName = gameObject.name; VRTK_SharedMethods.CloneComponent(storedJoint, obj, true); gameObject.name = storeName; givenJoint = obj.GetComponent(storedJoint.GetType()) as Joint; base.CreateJoint(obj); }
// Token: 0x06001D68 RID: 7528 RVA: 0x00096478 File Offset: 0x00094678 protected virtual void CopyCustomJoint() { if (this.customJoint) { this.jointHolder = new GameObject(); this.jointHolder.transform.SetParent(base.transform); this.jointHolder.AddComponent <Rigidbody>().isKinematic = true; VRTK_SharedMethods.CloneComponent(this.customJoint, this.jointHolder, true); this.jointHolder.name = VRTK_SharedMethods.GenerateVRTKObjectName(true, new object[] { "JointHolder" }); this.jointHolder.SetActive(false); Object.Destroy(this.customJoint); this.customJoint = this.jointHolder.GetComponent <Joint>(); } }
// Token: 0x06001D66 RID: 7526 RVA: 0x000963D4 File Offset: 0x000945D4 protected override void CreateJoint(GameObject obj) { if (!this.jointHolder) { VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, new object[] { "VRTK_CustomJointGrabAttach", "Joint", "customJoint", "the same" })); return; } Joint component = this.jointHolder.GetComponent <Joint>(); string name = base.gameObject.name; VRTK_SharedMethods.CloneComponent(component, obj, true); base.gameObject.name = name; this.givenJoint = (obj.GetComponent(component.GetType()) as Joint); base.CreateJoint(obj); }
protected virtual GameObject CreateHighlightModel(GameObject givenOutlineModel, string givenOutlineModelPath) { if (givenOutlineModel != null) { givenOutlineModel = (givenOutlineModel.GetComponent <Renderer>() ? givenOutlineModel : givenOutlineModel.GetComponentInChildren <Renderer>().gameObject); } else if (givenOutlineModelPath != "") { var getChildModel = transform.FindChild(givenOutlineModelPath); givenOutlineModel = (getChildModel ? getChildModel.gameObject : null); } GameObject copyModel = givenOutlineModel; if (copyModel == null) { copyModel = (GetComponent <Renderer>() ? gameObject : GetComponentInChildren <Renderer>().gameObject); } if (copyModel == null) { Debug.LogError("No Renderer has been found on the model to add highlighting to"); return(null); } GameObject highlightModel = new GameObject(name + "_HighlightModel"); highlightModel.transform.SetParent(copyModel.transform.parent, false); highlightModel.transform.localPosition = copyModel.transform.localPosition; highlightModel.transform.localRotation = copyModel.transform.localRotation; highlightModel.transform.localScale = copyModel.transform.localScale; highlightModel.transform.SetParent(transform); foreach (var component in copyModel.GetComponents <Component>()) { if (Array.IndexOf(copyComponents, component.GetType().ToString()) >= 0) { VRTK_SharedMethods.CloneComponent(component, highlightModel); } } var copyMesh = copyModel.GetComponent <MeshFilter>(); var highlightMesh = highlightModel.GetComponent <MeshFilter>(); if (highlightMesh) { if (enableSubmeshHighlight) { List <CombineInstance> combine = new List <CombineInstance>(); for (int i = 0; i < copyMesh.mesh.subMeshCount; i++) { CombineInstance ci = new CombineInstance(); ci.mesh = copyMesh.mesh; ci.subMeshIndex = i; ci.transform = copyMesh.transform.localToWorldMatrix; combine.Add(ci); } highlightMesh.mesh = new Mesh(); highlightMesh.mesh.CombineMeshes(combine.ToArray(), true, false); } else { highlightMesh.mesh = copyMesh.mesh; } highlightModel.GetComponent <Renderer>().material = stencilOutline; } highlightModel.SetActive(false); VRTK_PlayerObject.SetPlayerObject(highlightModel, VRTK_PlayerObject.ObjectTypes.Highlighter); return(highlightModel); }
// Token: 0x06001D3B RID: 7483 RVA: 0x00095A7C File Offset: 0x00093C7C protected virtual GameObject CreateHighlightModel(GameObject givenOutlineModel, string givenOutlineModelPath) { if (givenOutlineModel != null) { givenOutlineModel = (givenOutlineModel.GetComponent <Renderer>() ? givenOutlineModel : givenOutlineModel.GetComponentInChildren <Renderer>().gameObject); } else if (givenOutlineModelPath != "") { Transform transform = base.transform.Find(givenOutlineModelPath); givenOutlineModel = (transform ? transform.gameObject : null); } GameObject gameObject = givenOutlineModel; if (gameObject == null) { gameObject = (base.GetComponent <Renderer>() ? base.gameObject : base.GetComponentInChildren <Renderer>().gameObject); } if (gameObject == null) { VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, new object[] { "VRTK_OutlineObjectCopyHighlighter", "Renderer", "the same or child", " to add the highlighter to" })); return(null); } GameObject gameObject2 = new GameObject(base.name + "_HighlightModel"); gameObject2.transform.SetParent(gameObject.transform.parent, false); gameObject2.transform.localPosition = gameObject.transform.localPosition; gameObject2.transform.localRotation = gameObject.transform.localRotation; gameObject2.transform.localScale = gameObject.transform.localScale; gameObject2.transform.SetParent(base.transform); foreach (Component component in gameObject.GetComponents <Component>()) { if (Array.IndexOf <string>(this.copyComponents, component.GetType().ToString()) >= 0) { VRTK_SharedMethods.CloneComponent(component, gameObject2, false); } } MeshFilter component2 = gameObject.GetComponent <MeshFilter>(); MeshFilter component3 = gameObject2.GetComponent <MeshFilter>(); if (component3) { if (this.enableSubmeshHighlight) { List <CombineInstance> list = new List <CombineInstance>(); for (int j = 0; j < component2.mesh.subMeshCount; j++) { list.Add(new CombineInstance { mesh = component2.mesh, subMeshIndex = j, transform = component2.transform.localToWorldMatrix }); } component3.mesh = new Mesh(); component3.mesh.CombineMeshes(list.ToArray(), true, false); } else { component3.mesh = component2.mesh; } gameObject2.GetComponent <Renderer>().material = this.stencilOutline; } gameObject2.SetActive(false); VRTK_PlayerObject.SetPlayerObject(gameObject2, VRTK_PlayerObject.ObjectTypes.Highlighter); return(gameObject2); }
protected virtual Renderer CreateHighlightModel(GameObject givenOutlineModel, string givenOutlineModelPath) { if (givenOutlineModel != null) { givenOutlineModel = (givenOutlineModel.GetComponent <Renderer>() ? givenOutlineModel : givenOutlineModel.GetComponentInChildren <Renderer>().gameObject); } else if (givenOutlineModelPath != "") { Transform getChildModel = objectToAffect.transform.Find(givenOutlineModelPath); givenOutlineModel = (getChildModel ? getChildModel.gameObject : null); } GameObject copyModel = givenOutlineModel; if (copyModel == null) { Renderer copyModelRenderer = objectToAffect.GetComponentInChildren <Renderer>(); copyModel = (copyModelRenderer != null ? copyModelRenderer.gameObject : null); } if (copyModel == null) { VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_OutlineObjectCopyHighlighter", "Renderer", "the same or child", " to add the highlighter to")); return(null); } GameObject highlightModel = new GameObject(objectToAffect.name + "_HighlightModel"); highlightModel.transform.SetParent(copyModel.transform.parent, false); highlightModel.transform.localPosition = copyModel.transform.localPosition; highlightModel.transform.localRotation = copyModel.transform.localRotation; highlightModel.transform.localScale = copyModel.transform.localScale; highlightModel.transform.SetParent(objectToAffect.transform); Component[] copyModelComponents = copyModel.GetComponents <Component>(); for (int i = 0; i < copyModelComponents.Length; i++) { Component copyModelComponent = copyModelComponents[i]; if (Array.IndexOf(copyComponents, copyModelComponent.GetType().ToString()) >= 0) { VRTK_SharedMethods.CloneComponent(copyModelComponent, highlightModel); } } MeshFilter copyMesh = copyModel.GetComponent <MeshFilter>(); MeshFilter highlightMesh = highlightModel.GetComponent <MeshFilter>(); Renderer returnHighlightModel = highlightModel.GetComponent <Renderer>(); if (highlightMesh != null) { if (enableSubmeshHighlight) { HashSet <CombineInstance> combine = new HashSet <CombineInstance>(); for (int i = 0; i < copyMesh.mesh.subMeshCount; i++) { CombineInstance ci = new CombineInstance(); ci.mesh = copyMesh.mesh; ci.subMeshIndex = i; ci.transform = copyMesh.transform.localToWorldMatrix; combine.Add(ci); } highlightMesh.mesh = new Mesh(); highlightMesh.mesh.CombineMeshes(combine.ToArray(), true, false); } else { highlightMesh.mesh = copyMesh.mesh; } returnHighlightModel.material = stencilOutline; returnHighlightModel.shadowCastingMode = copyModel.transform.GetComponent <Renderer>().shadowCastingMode; } highlightModel.SetActive(false); VRTK_PlayerObject.SetPlayerObject(highlightModel, VRTK_PlayerObject.ObjectTypes.Highlighter); return(returnHighlightModel); }