mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-01 11:12:49 +08:00
Use switch expression instead of if/else block
This commit is contained in:
@ -28,17 +28,16 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
if (!typeof(UnityEngine.Object).IsAssignableFrom(targetType))
|
if (!typeof(UnityEngine.Object).IsAssignableFrom(targetType))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
UnityObjectWidget ret;
|
UnityObjectWidget widget = target switch
|
||||||
|
{
|
||||||
|
Texture2D => Pool<Texture2DWidget>.Borrow(),
|
||||||
|
AudioClip => Pool<AudioClipWidget>.Borrow(),
|
||||||
|
_ => Pool<UnityObjectWidget>.Borrow()
|
||||||
|
};
|
||||||
|
|
||||||
if (targetType == typeof(Texture2D))
|
widget.OnBorrowed(target, targetType, inspector);
|
||||||
ret = Pool<Texture2DWidget>.Borrow();
|
|
||||||
else if (targetType == typeof(AudioClip))
|
|
||||||
ret = Pool<AudioClipWidget>.Borrow();
|
|
||||||
else
|
|
||||||
ret = Pool<UnityObjectWidget>.Borrow();
|
|
||||||
|
|
||||||
ret.OnBorrowed(target, targetType, inspector);
|
return widget;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnBorrowed(object target, Type targetType, ReflectionInspector inspector)
|
public virtual void OnBorrowed(object target, Type targetType, ReflectionInspector inspector)
|
||||||
|
Reference in New Issue
Block a user