void Awake() { arrowwidth = EditorPrefs.GetFloat("MArrowWidth", 0.2f); arrowlength = EditorPrefs.GetFloat("MArrowLength", 1.1f); vertStart = EditorPrefs.GetFloat("MArrowStart", 0.2f); vertLength = EditorPrefs.GetFloat("MArrowvLength", 1.5f); arrowoff = EditorPrefs.GetFloat("MArrowOff", 0.8f); dashdist = EditorPrefs.GetFloat("MArrowDashDist", 2.0f); arrowCol.r = EditorPrefs.GetFloat("MArrowColR", 1.0f); arrowCol.g = EditorPrefs.GetFloat("MArrowColG", 1.0f); arrowCol.b = EditorPrefs.GetFloat("MArrowColB", 1.0f); arrowCol.a = EditorPrefs.GetFloat("MArrowColA", 1.0f); lineCol.r = EditorPrefs.GetFloat("MArrowLineColR", 1.0f); lineCol.g = EditorPrefs.GetFloat("MArrowLineColG", 1.0f); lineCol.b = EditorPrefs.GetFloat("MArrowLineColB", 1.0f); lineCol.a = EditorPrefs.GetFloat("MArrowLineColA", 1.0f); otherCol.r = EditorPrefs.GetFloat("MArrowOtherColR", 0.75f); otherCol.g = EditorPrefs.GetFloat("MArrowOtherColG", 0.75f); otherCol.b = EditorPrefs.GetFloat("MArrowOtherColB", 0.75f); otherCol.a = EditorPrefs.GetFloat("MArrowOtherColA", 1.0f); dashCol.r = EditorPrefs.GetFloat("MArrowDashColR", 0.5f); dashCol.g = EditorPrefs.GetFloat("MArrowDashColG", 0.5f); dashCol.b = EditorPrefs.GetFloat("MArrowDashColB", 0.5f); dashCol.a = EditorPrefs.GetFloat("MArrowDashColA", 1.0f); units = (MegaWireUnits)EditorPrefs.GetInt("MArrowUnits", (int)MegaWireUnits.Meters); unitsScale = EditorPrefs.GetFloat("MArrowLength", 1.1f); }
public static float GetUnitsScale(MegaWireUnits units, float scale) { switch (units) { case MegaWireUnits.Meters: return(1.0f * scale); case MegaWireUnits.Centimeters: return(100.0f * scale); case MegaWireUnits.Feet: return(3.28084f * scale); case MegaWireUnits.Inches: return(39.37f * scale); case MegaWireUnits.Yards: return(1.0936133f * scale); } return(scale); }
public static string GetUnitsString(MegaWireUnits units) { switch (units) { case MegaWireUnits.Meters: return("m"); case MegaWireUnits.Centimeters: return("cm"); case MegaWireUnits.Feet: return("ft"); case MegaWireUnits.Inches: return("in"); case MegaWireUnits.Yards: return("yds"); } return("m"); }
void OnGUI() { scroll = EditorGUILayout.BeginScrollView(scroll); if (picking) { if (GUILayout.Button("Stop Picking")) { picking = false; } } else { if (GUILayout.Button("Start Picking")) { picking = true; lastsel = null; // Ask if clear or add if (selection.Count > 0) { bool opt = EditorUtility.DisplayDialog("Add or Replace", "Do you want to Add to or Replace selection", "Add", "Replace"); if (opt == false) { selection.Clear(); } } } } // If we have a wire object selected then replace the selection if (GUILayout.Button("Create Wire")) { picking = false; MegaWire wire = MegaWire.Create(null, selection, material, wirename, copyfrom, 1.0f, 1.0f); copyfrom = wire; selection.Clear(); } wirename = EditorGUILayout.TextField("Wire Name", wirename); material = (Material)EditorGUILayout.ObjectField("Material", material, typeof(Material), true); copyfrom = (MegaWire)EditorGUILayout.ObjectField("Copy From", copyfrom, typeof(MegaWire), true); EditorGUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Current Selection"); for (int i = 0; i < selection.Count; i++) { EditorGUILayout.LabelField(i + ": " + selection[i].name); } EditorGUILayout.EndVertical(); showarrows = EditorGUILayout.Foldout(showarrows, "Arrow Params"); if (showarrows) { units = (MegaWireUnits)EditorGUILayout.EnumPopup("Units", units); unitsScale = EditorGUILayout.FloatField("Units Scale", unitsScale); arrowwidth = EditorGUILayout.FloatField("Arrow Width", arrowwidth); arrowlength = EditorGUILayout.FloatField("Arrow Length", arrowlength); arrowoff = EditorGUILayout.Slider("Arrow Offset", arrowoff, 0.0f, 1.0f); vertStart = EditorGUILayout.FloatField("Vert Start", vertStart); vertLength = EditorGUILayout.FloatField("Vert Length", vertLength); dashdist = EditorGUILayout.FloatField("Dash Dist", dashdist); lineCol = EditorGUILayout.ColorField("Line Color", lineCol); arrowCol = EditorGUILayout.ColorField("Arrow Color", arrowCol); otherCol = EditorGUILayout.ColorField("Other Color", otherCol); dashCol = EditorGUILayout.ColorField("Dash Color", dashCol); } EditorGUILayout.EndScrollView(); }