Created
April 2, 2018 21:47
-
-
Save dilanshah/d390e402083f8d358c5c7310c746b5ed to your computer and use it in GitHub Desktop.
Incomplete - design for importing fakemodel using scriptableObject (Unity resource which is an implementation of Object) at runtime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using System.IO; | |
// this goes into the editor folder | |
// we give it a specific scriptable object it will make that object for us | |
public static class ScriptableObjectUtility | |
{ | |
public static void CreateAsset<T> () where T : ScriptableObject | |
{ | |
T asset = ScriptableObject.CreateInstance<T> (); | |
string path = AssetDatabase.GetAssetPath(Selection.activeObject); // returns the path name relative to the project folder where the asset is stored. | |
if(path == "") | |
{ | |
path = "Assets"; | |
} | |
else if (Path.GetExtension(path) != "") // returns the file name, including the extension if any, of the specified path string | |
{ | |
Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject), ""); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment