Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[ScriptedImporter(1, "cube")]
public class PrimitiveImporter : ScriptedImporter
{
public PrimitiveType type = PrimitiveType.Cube;
public override void OnImportAsset(AssetImportContext ctx)
{
var cube = GameObject.CreatePrimitive(type);
cube.transform.localScale = new Vector3(1, 1, 1);
var material = new Material(Shader.Find("Standard"));
material.name = "Cube Material";
cube.GetComponent<MeshRenderer> ().material = material;
try
{
var scale = JsonUtility.FromJson<Vector3>(File.ReadAllText(ctx.assetPath));
cube.transform.localScale = scale;
}catch (System.Exception e) {
Debug.LogError (e.Message, cube);
}
ctx.AddObjectToAsset("mat", material);
ctx.AddObjectToAsset("CUBE", cube);
ctx.SetMainObject(cube);
}
}
@tsubaki

This comment has been minimized.

Copy link
Owner Author

commented Dec 13, 2017

animation 64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.