Skip to content

Commit 2515541

Browse files
committed
Add ScrollView support to CuiHelper
1 parent 0ad30f4 commit 2515541

File tree

1 file changed

+75
-2
lines changed

1 file changed

+75
-2
lines changed

src/RustCui.cs

+75-2
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public class CuiElement
204204

205205
[JsonProperty("fadeOut")]
206206
public float FadeOut { get; set; }
207-
207+
208208
[JsonProperty("update", NullValueHandling = NullValueHandling.Ignore)]
209209
public bool Update { get; set; }
210210
}
@@ -428,10 +428,13 @@ public class CuiNeedsKeyboardComponent : ICuiComponent
428428
public string Type => "NeedsKeyboard";
429429
}
430430

431-
public class CuiRectTransformComponent : ICuiComponent
431+
public class CuiRectTransformComponent : CuiRectTransform, ICuiComponent
432432
{
433433
public string Type => "RectTransform";
434+
}
434435

436+
public class CuiRectTransform
437+
{
435438
// The normalized position in the parent RectTransform that the lower left corner is anchored to
436439
[JsonProperty("anchormin")]
437440
public string AnchorMin { get; set; }
@@ -449,6 +452,72 @@ public class CuiRectTransformComponent : ICuiComponent
449452
public string OffsetMax { get; set; }
450453
}
451454

455+
public class CuiScrollViewComponent : ICuiComponent
456+
{
457+
public string Type => "UnityEngine.UI.ScrollView";
458+
459+
[JsonProperty("contentTransform")]
460+
public CuiRectTransform ContentTransform { get; set; }
461+
462+
[JsonProperty("horizontal")]
463+
public bool Horizontal { get; set; }
464+
465+
[JsonProperty("vertical")]
466+
public bool Vertical { get; set; }
467+
468+
[JsonProperty("movementType")]
469+
[JsonConverter(typeof(StringEnumConverter))]
470+
public ScrollRect.MovementType MovementType { get; set; }
471+
472+
[JsonProperty("elasticity")]
473+
public float Elasticity { get; set; }
474+
475+
[JsonProperty("inertia")]
476+
public bool Inertia { get; set; }
477+
478+
[JsonProperty("decelerationRate")]
479+
public float DecelerationRate { get; set; }
480+
481+
[JsonProperty("scrollSensitivity")]
482+
public float ScrollSensitivity { get; set; }
483+
484+
[JsonProperty("horizontalScrollbar")]
485+
public CuiScrollbar HorizontalScrollbar { get; set; }
486+
487+
[JsonProperty("verticalScrollbar")]
488+
public CuiScrollbar VerticalScrollbar { get; set; }
489+
}
490+
491+
public class CuiScrollbar
492+
{
493+
[JsonProperty("invert")]
494+
public bool Invert { get; set; }
495+
496+
[JsonProperty("autoHide")]
497+
public bool AutoHide { get; set; }
498+
499+
[JsonProperty("handleSprite")]
500+
public string HandleSprite { get; set; }
501+
502+
[JsonProperty("size")]
503+
public float Size { get; set; }
504+
505+
[JsonProperty("handleColor")]
506+
public string HandleColor { get; set; }
507+
508+
[JsonProperty("highlightColor")]
509+
public string HighlightColor { get; set; }
510+
511+
[JsonProperty("pressedColor")]
512+
public string PressedColor { get; set; }
513+
514+
[JsonProperty("trackSprite")]
515+
public string TrackSprite { get; set; }
516+
517+
[JsonProperty("trackColor")]
518+
public string TrackColor { get; set; }
519+
}
520+
452521
public class ComponentConverter : JsonConverter
453522
{
454523
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
@@ -504,6 +573,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
504573
type = typeof(CuiRectTransformComponent);
505574
break;
506575

576+
case "UnityEngine.UI.ScrollView":
577+
type = typeof(CuiScrollViewComponent);
578+
break;
579+
507580
default:
508581
return null;
509582
}

0 commit comments

Comments
 (0)