refactor(srp): introduce scriptableobject render asset substrate
This commit is contained in:
@@ -2,7 +2,8 @@ using XCEngine;
|
||||
|
||||
namespace XCEngine.Rendering
|
||||
{
|
||||
public abstract class RenderPipelineAsset : Object
|
||||
public abstract class RenderPipelineAsset
|
||||
: ScriptableObject
|
||||
{
|
||||
protected RenderPipelineAsset()
|
||||
{
|
||||
|
||||
45
managed/XCEngine.ScriptCore/ScriptableObject.cs
Normal file
45
managed/XCEngine.ScriptCore/ScriptableObject.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace XCEngine
|
||||
{
|
||||
public abstract class ScriptableObject : Object
|
||||
{
|
||||
protected ScriptableObject()
|
||||
{
|
||||
}
|
||||
|
||||
public static T CreateInstance<T>()
|
||||
where T : ScriptableObject
|
||||
{
|
||||
return CreateInstance(typeof(T)) as T;
|
||||
}
|
||||
|
||||
public static ScriptableObject CreateInstance(
|
||||
Type scriptableObjectType)
|
||||
{
|
||||
if (scriptableObjectType == null ||
|
||||
!typeof(ScriptableObject)
|
||||
.IsAssignableFrom(scriptableObjectType))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return Activator.CreateInstance(
|
||||
scriptableObjectType,
|
||||
BindingFlags.Instance |
|
||||
BindingFlags.Public |
|
||||
BindingFlags.NonPublic,
|
||||
binder: null,
|
||||
args: Array.Empty<object>(),
|
||||
culture: null) as ScriptableObject;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user