1
This commit is contained in:
@@ -426,15 +426,6 @@ namespace BITKit
|
||||
}
|
||||
return default;
|
||||
}
|
||||
public static bool TryGetComponentsInParent<T>(this GameObject self, out T[] components)
|
||||
{
|
||||
return TryGetComponentsInParent(self.transform, out components);
|
||||
}
|
||||
public static bool TryGetComponentsInParent<T>(this Component self, out T[] components)
|
||||
{
|
||||
components = self.GetComponentsInParent<T>();
|
||||
return components.IsValid();
|
||||
}
|
||||
public static bool TryGetComponentAny<T>(this Component self, out T component)
|
||||
{
|
||||
component = self.GetComponentInChildren<T>(true);
|
||||
@@ -597,24 +588,60 @@ namespace BITKit
|
||||
self.Add(clone);
|
||||
return clone;
|
||||
}
|
||||
public static bool Entry(this VisualElement self, string name,bool visibleOnEmpty=false)
|
||||
|
||||
public static bool Navigate(this VisualElement self, string name)
|
||||
{
|
||||
var result=false;
|
||||
foreach (var x in self.Children())
|
||||
while (true)
|
||||
{
|
||||
if (string.Equals(x.name, name))
|
||||
var result = false;
|
||||
|
||||
var split = name.Split("/");
|
||||
if (split.Length > 1)
|
||||
{
|
||||
x.SetActive(true);
|
||||
result = true;
|
||||
var root = self;
|
||||
var last = string.Empty;
|
||||
foreach (var path in split)
|
||||
{
|
||||
var ve = root.Q(path);
|
||||
if (ve is not null)
|
||||
{
|
||||
root = ve;
|
||||
last = path;
|
||||
}
|
||||
}
|
||||
|
||||
if (root != self)
|
||||
{
|
||||
self = root.parent;
|
||||
name = last;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x.SetActive(false);
|
||||
foreach (var x in self.Children())
|
||||
{
|
||||
if (string.Equals(x.name, name, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
x.SetActive(true);
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
x.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
self.SetActive(visibleOnEmpty || result);
|
||||
return result;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static T Get<T>(this VisualElement self ,int index = 0) where T : VisualElement => self.Q<T>($"{typeof(T).Name}--{index}");
|
||||
public static T Create<T>(this VisualElement self, string name = Constant.EmetyString) where T : VisualElement,new()
|
||||
{
|
||||
@@ -649,10 +676,12 @@ namespace BITKit
|
||||
public static void SetOpacity(this VisualElement self, float value) => self.style.opacity = new(value);
|
||||
public static void ScrollToBottom(this ScrollView self)
|
||||
{
|
||||
self.verticalScroller.value =
|
||||
self.verticalScroller.highValue > 0 ? self.verticalScroller.highValue : 0;
|
||||
self.schedule.Execute(() =>
|
||||
{
|
||||
self.scrollOffset = new Vector2(0, float.MaxValue);
|
||||
});
|
||||
}
|
||||
public static async void ScrollToBottomAutomatic(this ScrollView self, float delay = 0.02f)
|
||||
public static void ScrollToBottomAutomatic(this ScrollView self, float delay = 0.02f)
|
||||
{
|
||||
switch (true)
|
||||
{
|
||||
@@ -661,7 +690,6 @@ namespace BITKit
|
||||
case true when Math.Abs(self.verticalScroller.value - self.verticalScroller.highValue) < 0.01f:
|
||||
try
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(delay), BITApp.CancellationToken);
|
||||
ScrollToBottom(self);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
|
Reference in New Issue
Block a user