Skip to content

Instantly share code, notes, and snippets.

@HiromuKato HiromuKato/Cat.cs

Last active Nov 7, 2019
Embed
What would you like to do?
ねこちゃんオブジェクトを表示するスクリプト
using UnityEngine;
using UnityEditor;
[ExecuteInEditMode]
public class Cat : MonoBehaviour
{
public bool good = true;
[MenuItem("GameObject/3D Object/Cat", false, 10)]
static void CreateCat(MenuCommand menuCommand)
{
GameObject go = new GameObject("Cat");
double[] vx = { 0.000, 0.000, 0.000, 0.071, 0.041, 0.105, 0.123, 0.153, 0.094, 0.067, 0.000, 0.077, 0.088, 0.101, 0.137, 0.077, 0.087, 0.077, 0.150, 0.097, 0.077, 0.041, 0.068, 0.000, 0.031, 0.000, 0.059, 0.087, 0.095, 0.100, 0.078, 0.107, 0.000, 0.062, 0.095, 0.120, 0.128, 0.000, 0.000, 0.000, 0.107, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.076, 0.059, 0.000, 0.118, 0.014, 0.014, 0.000, 0.014, 0.000, 0.011, 0.000, 0.060, 0.014, 0.081, 0.124, 0.106, 0.103, 0.080, 0.103, 0.150, 0.104, 0.132, 0.113, 0.080, 0.080, 0.080, 0.085, 0.080, 0.085, 0.080, 0.108, 0.113, 0.113, 0.113, 0.113, 0.113, 0.113, 0.113, 0.113, 0.113, 0.113, 0.000, 0.000, 0.000, 0.072, 0.000, 0.072, 0.072, 0.072, 0.072, 0.072, 0.000, 0.000, 0.000, 0.051, 0.059, 0.046, 0.000, 0.011, 0.000, 0.014, 0.014, 0.000, 0.000, 0.000, 0.046, 0.046, 0.046, 0.046, 0.046, 0.052, 0.054, 0.072, 0.072, 0.072, 0.072, 0.072, 0.102, 0.104, 0.099, -0.071, -0.041, -0.105, -0.123, -0.153, -0.094, -0.067, -0.077, -0.088, -0.101, -0.137, -0.077, -0.087, -0.077, -0.150, -0.097, -0.077, -0.041, -0.068, -0.031, -0.059, -0.087, -0.095, -0.100, -0.078, -0.107, -0.062, -0.095, -0.120, -0.128, -0.107, -0.076, -0.059, -0.118, -0.014, -0.014, -0.014, -0.011, -0.060, -0.014, -0.081, -0.124, -0.106, -0.103, -0.080, -0.103, -0.150, -0.104, -0.132, -0.113, -0.080, -0.080, -0.080, -0.085, -0.080, -0.085, -0.080, -0.108, -0.113, -0.113, -0.113, -0.113, -0.113, -0.113, -0.113, -0.113, -0.113, -0.113, -0.072, -0.072, -0.072, -0.072, -0.072, -0.072, -0.051, -0.059, -0.046, -0.011, -0.014, -0.014, -0.046, -0.046, -0.046, -0.046, -0.046, -0.052, -0.054, -0.072, -0.072, -0.072, -0.072, -0.072, -0.102, -0.104, -0.099 };
double[] vy = { 0.185, 0.203, 0.155, 0.171, 0.150, 0.189, 0.211, 0.142, 0.128, 0.139, 0.239, 0.243, 0.229, 0.223, 0.193, 0.121, 0.265, 0.058, 0.047, 0.124, 0.000, 0.270, 0.272, 0.270, 0.259, 0.263, 0.240, 0.281, 0.284, 0.298, 0.287, 0.310, 0.217, 0.274, 0.240, 0.284, 0.240, 0.183, 0.136, 0.147, 0.118, 0.141, 0.000, -0.066, 0.040, 0.125, 0.081, 0.102, 0.081, 0.032, 0.058, 0.032, -0.050, -0.050, -0.141, -0.141, -0.247, -0.247, 0.003, 0.003, -0.069, -0.092, -0.114, -0.155, -0.131, -0.197, 0.070, -0.077, -0.088, -0.115, -0.271, -0.180, -0.273, -0.290, -0.306, -0.306, -0.295, -0.066, -0.106, -0.151, -0.217, -0.289, -0.147, -0.217, -0.279, -0.306, -0.291, -0.306, 0.082, 0.103, 0.129, -0.106, -0.106, -0.115, -0.151, -0.217, -0.279, -0.291, -0.106, -0.083, -0.095, -0.155, -0.197, -0.273, -0.259, -0.259, -0.164, -0.164, -0.058, -0.058, 0.003, -0.069, -0.131, -0.180, -0.271, -0.295, -0.306, -0.306, -0.290, -0.147, -0.217, -0.289, -0.306, -0.306, 0.239, 0.268, 0.279, 0.171, 0.150, 0.189, 0.211, 0.142, 0.128, 0.139, 0.243, 0.229, 0.223, 0.193, 0.121, 0.265, 0.058, 0.047, 0.124, 0.000, 0.270, 0.272, 0.259, 0.240, 0.281, 0.284, 0.298, 0.287, 0.310, 0.274, 0.240, 0.284, 0.240, 0.118, 0.102, 0.081, 0.058, 0.032, -0.050, -0.141, -0.247, 0.003, 0.003, -0.069, -0.092, -0.114, -0.155, -0.131, -0.197, 0.070, -0.077, -0.088, -0.115, -0.271, -0.180, -0.273, -0.290, -0.306, -0.306, -0.295, -0.066, -0.106, -0.151, -0.217, -0.289, -0.147, -0.217, -0.279, -0.306, -0.291, -0.306, -0.106, -0.115, -0.151, -0.217, -0.279, -0.291, -0.155, -0.197, -0.273, -0.259, -0.164, -0.058, -0.131, -0.180, -0.271, -0.295, -0.306, -0.306, -0.290, -0.147, -0.217, -0.289, -0.306, -0.306, 0.239, 0.268, 0.279 };
double[] vz = { 0.409, 0.398, 0.417, 0.395, 0.408, 0.387, 0.369, 0.328, 0.377, 0.397, 0.377, 0.311, 0.293, 0.280, 0.251, 0.176, 0.329, 0.294, 0.133, 0.126, 0.262, 0.337, 0.326, 0.334, 0.250, 0.241, 0.229, 0.304, 0.320, 0.305, 0.258, 0.286, 0.214, 0.253, 0.233, 0.272, 0.253, 0.200, 0.164, 0.126, -0.036, -0.036, 0.289, 0.263, 0.318, -0.269, -0.360, -0.269, -0.329, -0.384, -0.247, -0.384, -0.403, -0.403, -0.423, -0.423, -0.463, -0.463, -0.366, -0.381, -0.372, -0.203, -0.221, -0.275, -0.365, -0.321, -0.034, -0.031, 0.106, 0.142, -0.368, -0.365, -0.339, -0.305, -0.358, -0.305, -0.363, 0.263, 0.244, 0.218, 0.202, 0.190, 0.145, 0.160, 0.215, 0.250, 0.249, 0.203, 0.336, 0.374, 0.408, 0.244, 0.062, 0.142, 0.218, 0.202, 0.215, 0.249, -0.031, -0.117, -0.229, -0.275, -0.321, -0.339, -0.462, -0.462, -0.405, -0.405, -0.373, -0.373, -0.381, -0.372, -0.365, -0.365, -0.368, -0.363, -0.358, -0.305, -0.305, 0.145, 0.160, 0.190, 0.203, 0.250, 0.257, 0.268, 0.304, 0.395, 0.408, 0.387, 0.369, 0.328, 0.377, 0.397, 0.311, 0.293, 0.280, 0.251, 0.176, 0.329, 0.294, 0.133, 0.126, 0.262, 0.337, 0.326, 0.250, 0.229, 0.304, 0.320, 0.305, 0.258, 0.286, 0.253, 0.233, 0.272, 0.253, -0.036, -0.269, -0.329, -0.247, -0.384, -0.403, -0.423, -0.463, -0.366, -0.381, -0.372, -0.203, -0.221, -0.275, -0.365, -0.321, -0.034, -0.031, 0.106, 0.142, -0.368, -0.365, -0.339, -0.305, -0.358, -0.305, -0.363, 0.263, 0.244, 0.218, 0.202, 0.190, 0.145, 0.160, 0.215, 0.250, 0.249, 0.203, 0.244, 0.142, 0.218, 0.202, 0.215, 0.249, -0.275, -0.321, -0.339, -0.462, -0.405, -0.373, -0.365, -0.365, -0.368, -0.363, -0.358, -0.305, -0.305, 0.145, 0.160, 0.190, 0.203, 0.250, 0.257, 0.268, 0.304 };
int[] tris = new int[] { 3, 0, 2, 2, 4, 3, 5, 1, 0, 0, 3, 5, 1, 5, 6, 7, 5, 3, 7, 6, 5, 3, 8, 7, 9, 8, 3, 3, 4, 9, 6, 10, 1, 6, 7, 11, 7, 12, 11, 7, 13, 12, 14, 13, 7, 14, 7, 15, 11, 16, 6, 7, 17, 15, 15, 17, 18, 18, 19, 15, 18, 17, 20, 10, 6, 21, 6, 16, 22, 22, 21, 6, 21, 23, 10, 23, 21, 24, 24, 25, 23, 25, 24, 26, 27, 22, 16, 16, 28, 27, 27, 28, 29, 30, 27, 29, 22, 27, 30, 29, 31, 30, 26, 32, 25, 30, 33, 22, 26, 33, 30, 21, 22, 33, 33, 24, 21, 26, 24, 33, 34, 30, 31, 30, 34, 26, 31, 35, 34, 36, 34, 35, 34, 36, 14, 14, 26, 34, 32, 26, 14, 14, 37, 32, 37, 14, 15, 15, 38, 37, 38, 15, 19, 19, 39, 38, 39, 19, 40, 40, 19, 18, 40, 41, 39, 47, 45, 41, 41, 40, 47, 45, 47, 48, 48, 46, 45, 50, 47, 40, 48, 47, 50, 46, 48, 51, 51, 49, 46, 49, 51, 52, 52, 53, 49, 53, 52, 54, 54, 55, 53, 55, 54, 56, 56, 57, 55, 50, 58, 48, 48, 58, 59, 60, 58, 50, 50, 61, 60, 60, 61, 62, 60, 62, 63, 60, 63, 64, 63, 65, 64, 61, 50, 66, 40, 66, 50, 66, 67, 61, 18, 66, 40, 67, 66, 18, 18, 68, 67, 18, 69, 68, 65, 70, 64, 70, 71, 64, 65, 72, 70, 72, 73, 70, 73, 74, 70, 73, 75, 74, 74, 76, 70, 18, 77, 69, 18, 20, 77, 77, 78, 69, 69, 78, 79, 69, 79, 80, 69, 80, 81, 69, 81, 82, 81, 83, 82, 80, 84, 81, 84, 85, 81, 84, 86, 85, 85, 87, 81, 42, 20, 17, 20, 42, 43, 17, 44, 42, 44, 17, 7, 43, 77, 20, 7, 88, 44, 88, 7, 8, 8, 89, 88, 89, 8, 9, 9, 90, 89, 90, 9, 4, 4, 2, 90, 77, 43, 91, 91, 78, 77, 91, 43, 92, 92, 93, 91, 69, 93, 92, 78, 91, 94, 94, 79, 78, 79, 94, 95, 95, 80, 79, 80, 95, 96, 96, 84, 80, 84, 96, 97, 97, 86, 84, 92, 68, 69, 68, 92, 98, 98, 67, 68, 67, 98, 99, 99, 61, 67, 61, 99, 100, 100, 62, 61, 62, 100, 101, 101, 63, 62, 63, 101, 102, 102, 65, 63, 65, 102, 103, 103, 72, 65, 105, 104, 57, 57, 56, 105, 107, 106, 104, 104, 105, 107, 106, 107, 108, 108, 109, 106, 109, 108, 59, 59, 110, 109, 110, 59, 58, 60, 111, 110, 110, 58, 60, 111, 60, 64, 64, 112, 111, 112, 64, 71, 71, 113, 112, 113, 71, 70, 70, 114, 113, 114, 70, 76, 76, 115, 114, 115, 76, 74, 74, 116, 115, 108, 107, 105, 108, 105, 54, 105, 56, 54, 108, 54, 52, 108, 52, 51, 59, 108, 51, 48, 59, 51, 116, 74, 75, 75, 117, 116, 117, 75, 73, 73, 118, 117, 118, 73, 72, 72, 103, 118, 93, 69, 82, 82, 119, 93, 119, 82, 83, 83, 120, 119, 120, 83, 81, 81, 121, 120, 121, 81, 87, 87, 122, 121, 122, 87, 85, 85, 123, 122, 123, 85, 86, 86, 97, 123, 119, 120, 121, 119, 121, 95, 119, 95, 94, 119, 94, 91, 93, 119, 91, 121, 96, 95, 121, 123, 96, 121, 122, 123, 123, 97, 96, 112, 113, 114, 112, 114, 102, 114, 115, 102, 112, 102, 101, 111, 112, 101, 101, 100, 111, 115, 103, 102, 115, 117, 103, 115, 116, 117, 117, 118, 103, 12, 13, 124, 124, 125, 12, 12, 125, 126, 126, 11, 12, 16, 11, 126, 126, 28, 16, 28, 126, 29, 31, 29, 126, 126, 125, 31, 35, 31, 125, 125, 124, 35, 124, 36, 35, 14, 36, 124, 124, 13, 14, 127, 2, 0, 2, 127, 128, 129, 0, 1, 0, 129, 127, 1, 130, 129, 131, 127, 129, 131, 129, 130, 127, 131, 132, 133, 127, 132, 127, 133, 128, 130, 1, 10, 130, 134, 131, 131, 134, 135, 131, 135, 136, 137, 131, 136, 137, 138, 131, 134, 130, 139, 131, 138, 140, 138, 141, 140, 141, 138, 142, 141, 143, 140, 10, 144, 130, 130, 145, 139, 145, 130, 144, 144, 10, 23, 23, 146, 144, 146, 23, 25, 25, 147, 146, 148, 139, 145, 139, 148, 149, 148, 150, 149, 151, 150, 148, 145, 151, 148, 150, 151, 152, 147, 25, 32, 151, 145, 153, 147, 151, 153, 144, 153, 145, 153, 144, 146, 147, 153, 146, 154, 152, 151, 151, 147, 154, 152, 154, 155, 156, 155, 154, 154, 137, 156, 137, 154, 147, 32, 137, 147, 137, 32, 37, 37, 138, 137, 138, 37, 38, 38, 142, 138, 142, 38, 39, 39, 157, 142, 157, 141, 142, 157, 39, 41, 158, 41, 45, 41, 158, 157, 45, 159, 158, 159, 45, 46, 160, 157, 158, 159, 160, 158, 46, 161, 159, 161, 46, 49, 49, 162, 161, 162, 49, 53, 53, 163, 162, 163, 53, 55, 55, 164, 163, 164, 55, 57, 160, 159, 165, 159, 166, 165, 167, 160, 165, 160, 167, 168, 167, 169, 168, 167, 170, 169, 167, 171, 170, 170, 171, 172, 168, 173, 160, 157, 160, 173, 173, 168, 174, 141, 157, 173, 174, 141, 173, 141, 174, 175, 141, 175, 176, 172, 171, 177, 177, 171, 178, 172, 177, 179, 179, 177, 180, 180, 177, 181, 180, 181, 182, 181, 177, 183, 141, 176, 184, 141, 184, 143, 184, 176, 185, 176, 186, 185, 176, 187, 186, 176, 188, 187, 176, 189, 188, 188, 189, 190, 187, 188, 191, 191, 188, 192, 191, 192, 193, 192, 188, 194, 42, 140, 143, 143, 43, 42, 140, 42, 44, 44, 131, 140, 43, 143, 184, 131, 44, 88, 88, 132, 131, 132, 88, 89, 89, 133, 132, 133, 89, 90, 90, 128, 133, 128, 90, 2, 184, 195, 43, 195, 184, 185, 195, 92, 43, 92, 195, 196, 176, 92, 196, 185, 197, 195, 197, 185, 186, 186, 198, 197, 198, 186, 187, 187, 199, 198, 199, 187, 191, 191, 200, 199, 200, 191, 193, 92, 176, 175, 175, 98, 92, 98, 175, 174, 174, 99, 98, 99, 174, 168, 168, 100, 99, 100, 168, 169, 169, 201, 100, 201, 169, 170, 170, 202, 201, 202, 170, 172, 172, 203, 202, 203, 172, 179, 204, 57, 104, 57, 204, 164, 205, 104, 106, 104, 205, 204, 106, 206, 205, 206, 106, 109, 109, 166, 206, 166, 109, 110, 110, 165, 166, 167, 110, 111, 110, 167, 165, 111, 171, 167, 171, 111, 207, 207, 178, 171, 178, 207, 208, 208, 177, 178, 177, 208, 209, 209, 183, 177, 183, 209, 210, 210, 181, 183, 181, 210, 211, 206, 204, 205, 206, 163, 204, 204, 163, 164, 206, 162, 163, 206, 161, 162, 166, 161, 206, 159, 161, 166, 211, 182, 181, 182, 211, 212, 212, 180, 182, 180, 212, 213, 213, 179, 180, 179, 213, 203, 196, 189, 176, 189, 196, 214, 214, 190, 189, 190, 214, 215, 215, 188, 190, 188, 215, 216, 216, 194, 188, 194, 216, 217, 217, 192, 194, 192, 217, 218, 218, 193, 192, 193, 218, 200, 214, 216, 215, 214, 198, 216, 214, 197, 198, 214, 195, 197, 196, 195, 214, 216, 198, 199, 216, 199, 218, 216, 218, 217, 218, 199, 200, 207, 209, 208, 207, 202, 209, 209, 202, 210, 207, 201, 202, 111, 201, 207, 201, 111, 100, 210, 202, 203, 210, 203, 212, 210, 212, 211, 212, 203, 213, 135, 219, 136, 219, 135, 220, 135, 221, 220, 221, 135, 134, 139, 221, 134, 221, 139, 149, 149, 150, 221, 152, 221, 150, 221, 152, 220, 155, 220, 152, 220, 155, 219, 219, 155, 156, 137, 219, 156, 219, 137, 136 };
Vector3[] verts = new Vector3[vx.Length];
for (int n = 0; n < verts.Length; ++n)
{
verts[n] = new Vector3((float)vz[n], (float)vy[n], - (float)vx[n]);
}
go.AddComponent<Cat>();
MeshRenderer mr = go.AddComponent<MeshRenderer>();
MeshFilter mf = go.AddComponent<MeshFilter>();
Mesh mesh = new Mesh();
mesh.vertices = verts;
mesh.triangles = tris;
mesh.RecalculateNormals();
mf.mesh = mesh;
mr.material = new Material(Shader.Find("Standard"));
go.AddComponent<MeshCollider>();
// position at scene view focus point
Vector3 scenePos = SceneView.lastActiveSceneView.pivot;
go.transform.position = scenePos;
// Register the creation in the undo system
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
Debug.Log("Meow");
}
void Update()
{
// they're all good cats
good = true;
}
}
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.