public void Serialize(ref IntMath.Vector2i v) { if (isLoading) { v = ReadVector2i(); } else { Write(v); } }
public override bool Serialize(Archive archive, ISerializableObjectReferenceCollector collector, ref object field, object lastFieldState) { QuantizedVector2Field value = (QuantizedVector2Field)field; if (archive.isLoading) { IntMath.Vector2i q = new IntMath.Vector2i( archive.ReadSignedBits(value.FX.NUM_BITS), archive.ReadSignedBits(value.FY.NUM_BITS)); value.quantizedValue = q; } else { IntMath.Vector2i q = value.quantizedValue; archive.WriteSignedBits(q.x, value.FX.NUM_BITS); archive.WriteSignedBits(q.y, value.FY.NUM_BITS); } field = value; return archive.isLoading; }
public static IntMath.Vector2i MinMaxSlider(Rect rect, string label, IntMath.Vector2i range, int min, int max) { const int IntBoxWidth = 30; var r = EditorGUI.PrefixLabel(rect, new GUIContent(label)); var workRect = r; var oldIndent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; workRect.xMax = workRect.xMin + IntBoxWidth; range.x = Mathf.Clamp(EditorGUI.IntField(workRect, range.x), min, max); range.y = Mathf.Max(range.x, range.y); workRect = r; workRect.xMin += IntBoxWidth + 4; workRect.xMax -= IntBoxWidth + 4; float x = range.x; float y = range.y; EditorGUI.MinMaxSlider(workRect, ref x, ref y, min, max); range.x = Mathf.FloorToInt(x); range.y = Mathf.FloorToInt(y); workRect = r; workRect.xMin = workRect.xMax - IntBoxWidth; range.y = Mathf.Clamp(EditorGUI.IntField(workRect, range.y), min, max); range.x = Mathf.Min(range.x, range.y); EditorGUI.indentLevel = oldIndent; return(range); }
public static IntMath.Vector2i MinMaxSlider(string label, IntMath.Vector2i range, int min, int max) { return(MinMaxSlider(EditorGUILayout.GetControlRect(), label, range, min, max)); }
public virtual void Write(IntMath.Vector2i v) { Write(v.x); Write(v.y); }