forked from liortal53/ScriptableObjectFactory
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptableObjectFactory.cs
More file actions
33 lines (29 loc) · 911 Bytes
/
Copy pathScriptableObjectFactory.cs
File metadata and controls
33 lines (29 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
/// <summary>
/// A helper class for instantiating ScriptableObjects in the editor.
/// </summary>
public class ScriptableObjectFactory
{
[MenuItem("Assets/Create/ScriptableObject")]
public static void CreateScriptableObject()
{
var assembly = GetAssembly ();
// Get all classes derived from ScriptableObject
var allScriptableObjects = (from t in assembly.GetTypes()
where t.IsSubclassOf(typeof(ScriptableObject))
select t).ToArray();
// Show the selection window.
ScriptableObjectWindow.Init(allScriptableObjects);
}
/// <summary>
/// Returns the assembly that contains the script code for this project (currently hard coded)
/// </summary>
private static Assembly GetAssembly ()
{
return Assembly.Load (new AssemblyName ("Assembly-CSharp"));
}
}