Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
keijiro committed Nov 21, 2019
0 parents commit b9f5c89
Show file tree
Hide file tree
Showing 28 changed files with 1,978 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* -text

*.cs text eol=lf diff=csharp
*.shader text eol=lf
*.cginc text eol=lf
*.hlsl text eol=lf
*.compute text eol=lf

*.meta text eol=lf
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Windows
Thumbs.db
Desktop.ini

# macOS
.DS_Store

# Code Editors
/.idea
/.vscode
/*.csproj
/*.sln
*.swp
*.vcxproj.user

# Unity
/Library
/Logs
/Temp
8 changes: 8 additions & 0 deletions Assets/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions Assets/Editor/MgiImporter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using UnityEngine;
using UnityEngine.Rendering;
using UnityEditor;
using UnityEditor.Experimental.AssetImporters;
using Path = System.IO.Path;

namespace Mgi
{
[ScriptedImporter(1, "mgi")]
class MgiImporter : ScriptedImporter
{
#region ScriptedImporter implementation

public override void OnImportAsset(AssetImportContext context)
{
var gameObject = new GameObject();
var mesh = ImportAsMesh(context.assetPath);

var meshFilter = gameObject.AddComponent<MeshFilter>();
meshFilter.sharedMesh = mesh;

var meshRenderer = gameObject.AddComponent<MeshRenderer>();
meshRenderer.sharedMaterial =
AssetDatabase.GetBuiltinExtraResource<Material>("Default-Diffuse.mat");

context.AddObjectToAsset("prefab", gameObject);
if (mesh != null) context.AddObjectToAsset("mesh", mesh);

context.SetMainObject(gameObject);
}

#endregion

#region Reader implementation

Mesh ImportAsMesh(string path)
{
var mesh = new Mesh();
mesh.name = Path.GetFileNameWithoutExtension(path);
mesh.SetVertices(new [] { new Vector3(0, 0, 0), new Vector3(0, 1, 0), new Vector3(1, 0, 0) });
mesh.SetIndices(new [] { 0, 1, 2 }, MeshTopology.Triangles, 0);
mesh.UploadMeshData(true);
return mesh;
}

#endregion
}
}
11 changes: 11 additions & 0 deletions Assets/Editor/MgiImporter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b9f5c89

Please sign in to comment.