UnityEditor.SketchUpImporterModelEditor.CovertUnitToGlobalScale C# (CSharp) Method

CovertUnitToGlobalScale() private static method

private static CovertUnitToGlobalScale ( EFileUnit measurement, float unit ) : float
measurement EFileUnit
unit float
return float
        private static float CovertUnitToGlobalScale(EFileUnit measurement, float unit)
        {
            switch (measurement)
            {
                case EFileUnit.Meters:
                    return (0.0254f * unit);

                case EFileUnit.Centimeters:
                    return (0.000254f * unit);

                case EFileUnit.Millimeters:
                    return (unit * 2.54E-05f);

                case EFileUnit.Feet:
                    return (unit * 0.00774192f);

                case EFileUnit.Inches:
                    return unit;
            }
            Debug.LogError("File Unit value is invalid");
            return 1f;
        }

Usage Example

 public override void OnInspectorGUI()
 {
     GUILayout.Label(SketchUpImporterModelEditor.Styles.sketchUpLabel, EditorStyles.boldLabel, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_GenerateBackFace, SketchUpImporterModelEditor.Styles.generateBackFaceLabel, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_MergeCoplanarFaces, SketchUpImporterModelEditor.Styles.mergeCoplanarFaces, new GUILayoutOption[0]);
     EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
     GUILayout.Label(SketchUpImporterModelEditor.Styles.fileUnitLabel, new GUILayoutOption[]
     {
         GUILayout.MinWidth(EditorGUIUtility.labelWidth)
     });
     GUILayout.Label("1", new GUILayoutOption[0]);
     EditorGUILayout.Popup(this.m_FileUnit, SketchUpImporterModelEditor.Styles.measurementOptions, GUIContent.Temp(string.Empty), new GUILayoutOption[]
     {
         GUILayout.MaxWidth(100f)
     });
     this.lengthToUnit = SketchUpImporterModelEditor.ConvertGlobalScaleToUnit((SketchUpImporterModelEditor.EFileUnit) this.m_FileUnit.intValue, this.m_GlobalScale.floatValue);
     GUILayout.Label("=", new GUILayoutOption[0]);
     this.lengthToUnit             = EditorGUILayout.FloatField(this.lengthToUnit, new GUILayoutOption[0]);
     this.m_GlobalScale.floatValue = SketchUpImporterModelEditor.CovertUnitToGlobalScale((SketchUpImporterModelEditor.EFileUnit) this.m_FileUnit.intValue, this.lengthToUnit);
     EditorGUILayout.EndHorizontal();
     using (new EditorGUI.DisabledScope(true))
     {
         EditorGUILayout.FloatField(SketchUpImporterModelEditor.Styles.longitudeLabel, this.m_Longitude.floatValue, new GUILayoutOption[0]);
         EditorGUILayout.FloatField(SketchUpImporterModelEditor.Styles.latitudeLabel, this.m_Latitude.floatValue, new GUILayoutOption[0]);
         EditorGUILayout.FloatField(SketchUpImporterModelEditor.Styles.northCorrectionLabel, this.m_NorthCorrection.floatValue, new GUILayoutOption[0]);
     }
     EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
     if (GUILayout.Button(SketchUpImporterModelEditor.Styles.selectNodeButton, new GUILayoutOption[0]))
     {
         SketchUpNodeInfo[] nodes = this.m_Target.GetNodes();
         SketchUpImportDlg.Launch(nodes, this);
         GUIUtility.ExitGUI();
     }
     GUILayout.FlexibleSpace();
     EditorGUILayout.EndHorizontal();
     base.OnInspectorGUI();
 }