public override void OnInspectorGUI() { Preview preview = (Preview)target; EditorGUILayout.HelpBox("The dark blue arrow points towards the viewer.", MessageType.Info); if (GUILayout.Button("Align with camera")) { Preview script = target as Preview; SceneView.RepaintAll(); SceneView.lastActiveSceneView.camera.transform.position -= 2 * script.transform.position; script.transform.LookAt(-SceneView.lastActiveSceneView.camera.transform.position); SceneView.lastActiveSceneView.camera.transform.position += 2 * script.transform.position; } }
public override void OnInspectorGUI() { Preview preview = (Preview)target; EditorGUILayout.HelpBox("The dark blue arrow points towards the viewer.", MessageType.Info); }
protected virtual void OnValidate() { if (!gameObject.activeInHierarchy) { return; } holderPoint = transform.Find("HolderPoint"); if (!holderPoint) { holderPoint = new GameObject("HolderPoint").transform; holderPoint.SetParent(transform, false); } parryPoint = transform.Find("ParryPoint"); if (!parryPoint) { parryPoint = new GameObject("ParryPoint").transform; parryPoint.SetParent(transform, false); } preview = GetComponentInChildren <Preview>(); if (!preview && transform.Find("Preview")) { preview = transform.Find("Preview").gameObject.AddComponent <Preview>(); } if (!preview) { preview = new GameObject("Preview").AddComponent <Preview>(); preview.transform.SetParent(transform, false); } whoosh = GetComponentInChildren <WhooshPoint>(); if (!whoosh && transform.Find("Whoosh")) { whoosh = transform.Find("Whoosh").gameObject.AddComponent <WhooshPoint>(); } if (!whoosh) { whoosh = new GameObject("Whoosh").AddComponent <WhooshPoint>(); whoosh.transform.SetParent(transform, false); } foreach (MeshRenderer mesh in GetComponentsInChildren <MeshRenderer>()) { if (!mesh.GetComponent <Paintable>()) { mesh.gameObject.AddComponent <Paintable>(); } } if (!mainHandleRight) { foreach (HandleDefinition handleDefinition in GetComponentsInChildren <HandleDefinition>()) { if (handleDefinition.IsAllowed(Side.Right)) { mainHandleRight = handleDefinition; break; } } } if (!mainHandleLeft) { foreach (HandleDefinition handleDefinition in GetComponentsInChildren <HandleDefinition>()) { if (handleDefinition.IsAllowed(Side.Left)) { mainHandleLeft = handleDefinition; break; } } } if (!mainHandleRight) { mainHandleRight = GetComponentInChildren <HandleDefinition>(); } if (useCustomCenterOfMass) { GetComponent <Rigidbody>().centerOfMass = customCenterOfMass; } else { GetComponent <Rigidbody>().ResetCenterOfMass(); } if (customInertiaTensor) { if (customInertiaTensorCollider == null) { Transform foundInertiaTensor = GetComponentInParent <ItemDefinition>().transform.Find("InertiaTensorCollider"); if (foundInertiaTensor) { customInertiaTensorCollider = foundInertiaTensor.GetComponent <CapsuleCollider>(); } } if (customInertiaTensorCollider == null) { customInertiaTensorCollider = new GameObject("InertiaTensorCollider").AddComponent <CapsuleCollider>(); customInertiaTensorCollider.transform.SetParent(transform, false); customInertiaTensorCollider.radius = 0.05f; customInertiaTensorCollider.direction = 2; } customInertiaTensorCollider.enabled = false; customInertiaTensorCollider.isTrigger = true; customInertiaTensorCollider.gameObject.layer = 2; } else { customInertiaTensorCollider = null; } }