public override void OnInspectorGUI() { base.DrawDefaultInspector(); Cone cone = target as Cone; if (cone == null) { return; } EditorGUILayout.BeginHorizontal(); // Rebuild mesh when user click the Rebuild button if (GUILayout.Button("Rebuild")) { // check parameter if (cone.CheckParam()) { // update parameter cone.UpdateParam(false); // build mesh cone.BuildMesh(); } } // Reset to last successul build parameter if (GUILayout.Button("Reset")) { cone.UpdateParam(true); } EditorGUILayout.EndHorizontal(); }
static void Create() { GameObject gameObject = new GameObject("Cone"); Cone cone = gameObject.AddComponent <Cone>(); gameObject.AddComponent <MeshCollider>(); gameObject.AddComponent <MeshFilter>(); MeshRenderer renderer = gameObject.AddComponent <MeshRenderer>(); renderer.sharedMaterial = new Material(Shader.Find("Standard")); renderer.sharedMaterial.SetColor("_Color", Color.white); // build mesh cone.BuildMesh(); }