public static string GetAbbreviation(LevelUnit unit, [CanBeNull] Culture culture) { return(UnitSystem.GetCached(culture).GetDefaultAbbreviation(unit)); }
public static void HasConversion(this PropertyBuilder <Level> propertyBuilder, LevelUnit unit) => propertyBuilder.HasConversion(v => v.As(unit), v => new Level(v, unit));
/// <summary> /// Converts this Level to another Level with the unit representation <paramref name="unit" />. /// </summary> /// <returns>A Level with the specified unit.</returns> public Level ToUnit(LevelUnit unit) { var convertedValue = AsBaseNumericType(unit); return(new Level(convertedValue, unit)); }
public static Level From(double value, LevelUnit fromUnit)
public static string GetAbbreviation(LevelUnit unit) { return(GetAbbreviation(unit, null)); }
/// <summary> /// Dynamically convert from value and unit enum <see cref="LevelUnit" /> to <see cref="Level" />. /// </summary> /// <param name="value">Value to convert from.</param> /// <param name="fromUnit">Unit to convert from.</param> /// <returns>Level unit value.</returns> public static Level?From(QuantityValue?value, LevelUnit fromUnit) { return(value.HasValue ? new Level((double)value.Value, fromUnit) : default(Level?)); }
public static string GetAbbreviation(LevelUnit unit, [CanBeNull] IFormatProvider provider) { provider = provider ?? UnitSystem.DefaultCulture; return(UnitSystem.GetCached(provider).GetDefaultAbbreviation(unit)); }
public string ToString(LevelUnit unit, CultureInfo culture, string format, params object[] args) { return(string.Format(culture, format, UnitFormatter.GetFormatArgs(unit, As(unit), culture, args))); }
/// <summary> /// Get unit abbreviation string. /// </summary> /// <param name="unit">Unit to get abbreviation for.</param> /// <returns>Unit abbreviation string.</returns> /// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param> public static string GetAbbreviation(LevelUnit unit, [CanBeNull] string cultureName) { IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); return(UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider)); }
public static string GetAbbreviation(LevelUnit unit, CultureInfo culture = null) { return(UnitSystem.GetCached(culture).GetDefaultAbbreviation(unit)); }
public string ToString(LevelUnit unit, CultureInfo culture = null, int significantDigitsAfterRadix = 2) { return(ToString(unit, culture, UnitFormatter.GetFormat(As(unit), significantDigitsAfterRadix))); }
/// <summary> /// Creates the quantity with the given numeric value and unit. /// </summary> /// <param name="value">The numeric value to construct this quantity with.</param> /// <param name="unit">The unit representation to construct this quantity with.</param> /// <exception cref="ArgumentException">If value is NaN or Infinity.</exception> public Level(double value, LevelUnit unit) { _value = value; _unit = unit; }
/// <summary> /// Converts this Duration to another Duration with the unit representation <paramref name="unit" />. /// </summary> /// <returns>A Duration with the specified unit.</returns> public Level ToUnit(LevelUnit unit) { var convertedValue = GetValueAs(unit); return(new Level(convertedValue, unit)); }
/// <summary> /// Convert to the unit representation <paramref name="unit" />. /// </summary> /// <returns>Value converted to the specified unit.</returns> public double As(LevelUnit unit) => GetValueAs(unit);
/// <summary> /// Get string representation of value and unit. Using current UI culture and two significant digits after radix. /// </summary> /// <param name="unit">Unit representation to use.</param> /// <returns>String representation.</returns> public string ToString(LevelUnit unit) { return(ToString(unit, null, 2)); }
public static Level From(double value, LevelUnit fromUnit) { return(new Level((double)value, fromUnit)); }
/// <summary> /// Get string representation of value and unit. Using two significant digits after radix. /// </summary> /// <param name="unit">Unit representation to use.</param> /// <param name="culture">Culture to use for localization and number formatting.</param> /// <returns>String representation.</returns> public string ToString(LevelUnit unit, [CanBeNull] Culture culture) { return(ToString(unit, culture, 2)); }
public static bool TryParseUnit(string str, out LevelUnit unit) { return(TryParseUnit(str, null, out unit)); }
/// <summary> /// Get string representation of value and unit. Using two significant digits after radix. /// </summary> /// <param name="unit">Unit representation to use.</param> /// <param name="provider">Format to use for localization and number formatting. Defaults to <see cref="UnitSystem.DefaultCulture" />.</param> /// <returns>String representation.</returns> public string ToString(LevelUnit unit, [CanBeNull] IFormatProvider provider) { return(ToString(unit, provider, 2)); }
/// <summary> /// Parse a unit string. /// </summary> /// <param name="str">String to parse. Typically in the form: {number} {unit}</param> /// <param name="unit">The parsed unit if successful.</param> /// <returns>True if successful, otherwise false.</returns> /// <example> /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// </example> /// <param name="cultureName">Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to <see cref="GlobalConfiguration.DefaultCulture" /> if null.</param> public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out LevelUnit unit) { IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); return(UnitParser.Default.TryParse <LevelUnit>(str, provider, out unit)); }
Level(double numericValue, LevelUnit unit) { _value = numericValue; _unit = unit; }
public static void renderGUI(int vpos) { vpos += OET_lib.ToolLib.header("<b>Init / Save / Load</b>\nSave or Load the Scene with JSON.", vpos, false); int width = Screen.width; float btWidth = width < 160 ? width - 20 : 160; GUI.Label(new Rect(10, vpos, 150, 20), "+x"); Num_x = EditorGUI.IntSlider(new Rect(90, vpos, width - 100, 20), Num_x, 1, 20); GUI.Label(new Rect(10, vpos + 50, 150, 20), "+z"); Num_z = EditorGUI.IntSlider(new Rect(90, vpos + 50, width - 100, 20), Num_z, 1, 20); GUI.enabled = !OET_io.lib.LevelIsLoaded; // Init button if (GUI.Button(new Rect(width / 2 - btWidth / 2, vpos + 100, btWidth, 25), "Init") && initialized == false) { // This will force a database reload new LevelObjectDatabase(); GameObject _platform = new GameObject("LOADED LEVEL"); _CreateSingleton(); Undo.RegisterCreatedObjectUndo(_platform, "Init the level"); //GameObject _prefab = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Old/Environment/Hallway/Hallway_Floor.prefab", typeof(GameObject)) as GameObject; for (int i = -Num_x; i <= Num_x; i++) { for (int j = -Num_z; j <= Num_z; j++) { GameObject _instance = Instantiate(tileObject.Prefab, new Vector3(i * OET_grid.lib.size_x, 0, j * OET_grid.lib.size_z), Quaternion.identity); _instance.name = tileObject.Path; //Edge + Wall if (i == -Num_x || i == Num_x || j == -Num_z || j == Num_z) { _AddNavMeshModifier(_instance, OET_lib.NavMeshAreas.NotWalkable); GameObject _wall = Instantiate(tileObject.Prefab, new Vector3(i * OET_grid.lib.size_x, OET_grid.lib.size_y, j * OET_grid.lib.size_z), Quaternion.identity); _wall.transform.SetParent(_platform.transform); Undo.RegisterCreatedObjectUndo(_wall, "Init the level"); OET_io.lib.ActiveGameObjects.Add(_wall); _AddNavMeshModifier(_wall, OET_lib.NavMeshAreas.NotWalkable); } else if (_instance.GetComponent <LevelUnit>() == null) { LevelUnit LU = _instance.AddComponent <LevelUnit>() as LevelUnit; LU.defaultState = LevelUnitStates.Floor; _AddNavMeshModifier(_instance, OET_lib.NavMeshAreas.Walkable); } _instance.transform.SetParent(_platform.transform); Undo.RegisterCreatedObjectUndo(_instance, "Init the level"); OET_io.lib.ActiveGameObjects.Add(_instance); } } GameObject NavSurface = GameObject.Find("NavMeshSurface"); if (NavSurface) { NavSurface.GetComponent <NavMeshSurface>().BuildNavMesh(); } OET_io.lib.SetDirty(true); } tileObject = EditorGUI.ObjectField( new Rect(width / 2 + btWidth / 2 + 8, vpos + 100, btWidth, 25), tileObject, typeof(LevelEditorObject)) as LevelEditorObject; GUI.enabled = OET_io.lib.LevelIsLoaded; // Save button if (GUI.Button(new Rect(width / 2 - btWidth / 2, vpos + 150, btWidth, 25), "Save")) { OET_io.lib.SaveCurrentLevel(); } // Save As button if (GUI.Button(new Rect(width / 2 - btWidth / 2, vpos + 200, btWidth, 25), "Save As")) { string savePath = EditorUtility.SaveFilePanel("Save Level", Application.dataPath, "New Level.level", "level"); if (savePath == "" || savePath == default(string)) { return; } OET_io.lib.SaveCurrentLevel(savePath); } // Close button if (GUI.Button(new Rect(width / 2 - btWidth / 2, vpos + 250, btWidth, 25), "Close")) { if (OET_io.lib.IsDirty) { switch (EditorUtility.DisplayDialogComplex( "Save Level", "Do you want to save your level?", "Save", "Don't Save", "Cancel")) { case 0: // Save string savePath = EditorUtility.SaveFilePanel("Save Level", Application.dataPath, "New Level.level", "level"); if (savePath == "" || savePath == default(string)) { return; } OET_io.lib.SaveCurrentLevel(savePath); OET_io.lib.CloseLevel(); break; case 1: // Don't Save OET_io.lib.CloseLevel(); break; case 2: // Cancel break; } } OET_io.lib.CloseLevel(); } GUI.enabled = true; // Load button if (GUI.Button(new Rect(width / 2 - btWidth / 2, vpos + 300, btWidth, 25), "Load")) { if (OET_io.lib.LevelIsLoaded && OET_io.lib.IsDirty) { switch (EditorUtility.DisplayDialogComplex( "Save Level", "Do you want to save your level?", "Save", "Don't Save", "Cancel")) { case 0: // Save string savePath = EditorUtility.SaveFilePanel("Save Level", Application.dataPath, "New Level.level", "level"); if (savePath == "" || savePath == default(string)) { return; } OET_io.lib.SaveCurrentLevel(savePath); OET_io.lib.CloseLevel(); break; case 1: // Don't Save OET_io.lib.CloseLevel(); break; case 2: // Cancel break; } } string openPath = EditorUtility.OpenFilePanel("Open Level", Application.dataPath, "level"); if (openPath == "" || openPath == default(string)) { return; } OET_io.lib.OpenLevel(openPath); } }
public static Level From(QuantityValue value, LevelUnit fromUnit) #endif { return(new Level((double)value, fromUnit)); }
/// <summary> /// Get string representation of value and unit. Using two significant digits after radix. /// </summary> /// <param name="unit">Unit representation to use.</param> /// <param name="cultureName">Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to <see cref="UnitSystem" />'s default culture.</param> /// <returns>String representation.</returns> public string ToString(LevelUnit unit, [CanBeNull] string cultureName) { return(ToString(unit, cultureName, 2)); }
public static string GetAbbreviation( LevelUnit unit, #if WINDOWS_UWP [CanBeNull] string cultureName)
public string ToString(LevelUnit unit, [CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix) { double value = As(unit); string format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); return ToString(unit, provider, format); }