Measurement script that takes a StartPosition and an EndPosition
This commit is contained in:
@@ -0,0 +1,77 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 01d5f3c1f0a08a44bac3aabe83dd15cb
|
||||||
|
timeCreated: 1464109925
|
||||||
|
licenseType: Free
|
||||||
|
ModelImporter:
|
||||||
|
serializedVersion: 19
|
||||||
|
fileIDToRecycleName:
|
||||||
|
100000: //RootNode
|
||||||
|
400000: //RootNode
|
||||||
|
2300000: //RootNode
|
||||||
|
3300000: //RootNode
|
||||||
|
4300000: SM_Door
|
||||||
|
9500000: //RootNode
|
||||||
|
materials:
|
||||||
|
importMaterials: 1
|
||||||
|
materialName: 0
|
||||||
|
materialSearch: 1
|
||||||
|
animations:
|
||||||
|
legacyGenerateAnimations: 4
|
||||||
|
bakeSimulation: 0
|
||||||
|
resampleRotations: 1
|
||||||
|
optimizeGameObjects: 0
|
||||||
|
motionNodeName:
|
||||||
|
animationImportErrors:
|
||||||
|
animationImportWarnings:
|
||||||
|
animationRetargetingWarnings:
|
||||||
|
animationDoRetargetingWarnings: 0
|
||||||
|
animationCompression: 1
|
||||||
|
animationRotationError: 0.5
|
||||||
|
animationPositionError: 0.5
|
||||||
|
animationScaleError: 0.5
|
||||||
|
animationWrapMode: 0
|
||||||
|
extraExposedTransformPaths: []
|
||||||
|
clipAnimations: []
|
||||||
|
isReadable: 1
|
||||||
|
meshes:
|
||||||
|
lODScreenPercentages: []
|
||||||
|
globalScale: 1
|
||||||
|
meshCompression: 0
|
||||||
|
addColliders: 0
|
||||||
|
importBlendShapes: 1
|
||||||
|
swapUVChannels: 0
|
||||||
|
generateSecondaryUV: 0
|
||||||
|
useFileUnits: 1
|
||||||
|
optimizeMeshForGPU: 1
|
||||||
|
keepQuads: 0
|
||||||
|
weldVertices: 1
|
||||||
|
secondaryUVAngleDistortion: 8
|
||||||
|
secondaryUVAreaDistortion: 15.000001
|
||||||
|
secondaryUVHardAngle: 88
|
||||||
|
secondaryUVPackMargin: 4
|
||||||
|
useFileScale: 1
|
||||||
|
tangentSpace:
|
||||||
|
normalSmoothAngle: 60
|
||||||
|
normalImportMode: 0
|
||||||
|
tangentImportMode: 3
|
||||||
|
importAnimation: 1
|
||||||
|
copyAvatar: 0
|
||||||
|
humanDescription:
|
||||||
|
human: []
|
||||||
|
skeleton: []
|
||||||
|
armTwist: 0.5
|
||||||
|
foreArmTwist: 0.5
|
||||||
|
upperLegTwist: 0.5
|
||||||
|
legTwist: 0.5
|
||||||
|
armStretch: 0.05
|
||||||
|
legStretch: 0.05
|
||||||
|
feetSpacing: 0
|
||||||
|
rootMotionBoneName:
|
||||||
|
hasTranslationDoF: 0
|
||||||
|
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||||
|
animationType: 2
|
||||||
|
humanoidOversampling: 1
|
||||||
|
additionalBone: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
public class Measurement : MonoBehaviour {
|
||||||
|
|
||||||
|
public Vector3 StartPosition;
|
||||||
|
public Vector3 EndPosition;
|
||||||
|
private float HoleSize = 0.1f;
|
||||||
|
private Vector3 lineUp = new Vector3(0, 1, 0);
|
||||||
|
// Use this for initialization
|
||||||
|
void Start () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update () {
|
||||||
|
Transform line1Transform = transform.FindChild("Line1");
|
||||||
|
LineRenderer line1Renderer = line1Transform.GetComponent<LineRenderer>();
|
||||||
|
|
||||||
|
Transform line2Transform = transform.FindChild("Line2");
|
||||||
|
LineRenderer line2Renderer = line2Transform.GetComponent<LineRenderer>();
|
||||||
|
|
||||||
|
Vector3 middlePosition = (StartPosition + (EndPosition - StartPosition) / 2.0f);
|
||||||
|
|
||||||
|
float magnitude = (EndPosition - StartPosition).magnitude;
|
||||||
|
Vector3 direction = Vector3.Normalize(EndPosition - StartPosition);
|
||||||
|
|
||||||
|
line1Renderer.SetPosition(0, StartPosition);
|
||||||
|
line1Renderer.SetPosition(1, middlePosition - (direction * HoleSize));
|
||||||
|
|
||||||
|
line2Renderer.SetPosition(0, middlePosition +(direction * HoleSize));
|
||||||
|
line2Renderer.SetPosition(1, EndPosition);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Transform textTransform = transform.FindChild("Text");
|
||||||
|
textTransform.position = middlePosition;
|
||||||
|
|
||||||
|
if (Camera.current != null)
|
||||||
|
{
|
||||||
|
textTransform.LookAt(Vector3.Normalize(textTransform.position - Camera.current.transform.position) + textTransform.position);
|
||||||
|
lineUp = Vector3.Normalize(Vector3.Cross(middlePosition - Camera.current.transform.position, EndPosition - StartPosition));
|
||||||
|
}
|
||||||
|
|
||||||
|
TextMesh textMesh = textTransform.GetComponent<TextMesh>();
|
||||||
|
textMesh.text = magnitude.ToString("0.00") + "m";
|
||||||
|
|
||||||
|
|
||||||
|
textMesh.characterSize = Mathf.Max(0.001f * Math.Min(1.0f , magnitude), 0.0005f);
|
||||||
|
|
||||||
|
HoleSize = Mathf.Max(0.1f * Math.Min(1.0f, magnitude), 0.05f);
|
||||||
|
|
||||||
|
Transform line1BaseTransform = transform.FindChild("Line1Base");
|
||||||
|
LineRenderer line1BaseRenderer = line1BaseTransform.GetComponent<LineRenderer>();
|
||||||
|
|
||||||
|
line1BaseRenderer.SetPosition(0, StartPosition + lineUp * 0.01f);
|
||||||
|
line1BaseRenderer.SetPosition(1, StartPosition - lineUp * 0.01f);
|
||||||
|
|
||||||
|
|
||||||
|
Transform line2BaseTransform = transform.FindChild("Line2Base");
|
||||||
|
LineRenderer line2BaseRenderer = line2BaseTransform.GetComponent<LineRenderer>();
|
||||||
|
|
||||||
|
line2BaseRenderer.SetPosition(0, EndPosition + lineUp * 0.01f);
|
||||||
|
line2BaseRenderer.SetPosition(1, EndPosition - lineUp * 0.01f);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 21b20d37384de2544b4550fbb626933b
|
||||||
|
timeCreated: 1464021124
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4bed37c8deedb404f976bbd7855a901b
|
||||||
|
timeCreated: 1464022811
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 93a82abf604e3454cb1d55f0c5f34370
|
||||||
|
timeCreated: 1464019744
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user