Skip to content

Instantly share code, notes, and snippets.

@dilanshah
Created April 2, 2018 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dilanshah/d390e402083f8d358c5c7310c746b5ed to your computer and use it in GitHub Desktop.
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
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