public static void RebuildMetaballMesh() { GameObject go = Selection.activeGameObject; ImplicitSurfaceMeshCreaterBase generator = Utils.FindComponentInParents <ImplicitSurfaceMeshCreaterBase>(go.transform); if (generator != null) { generator.CreateMesh(); } }
static void SaveMetaball(bool bMeshOnly) { Object [] selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.Assets); string defaultPath = "Assets"; if (selection != null && selection.Length > 0) { defaultPath = AssetDatabase.GetAssetPath(selection[0]); } GameObject go = Selection.activeGameObject; ImplicitSurfaceMeshCreaterBase seed = Utils.FindComponentInParents <ImplicitSurfaceMeshCreaterBase>(go.transform); string path = EditorUtility.SaveFilePanel("select folder and input filename", defaultPath, seed.gameObject.name, ""); string assetsRoot = Application.dataPath; if (path.StartsWith(assetsRoot)) { path = path.Remove(0, assetsRoot.Length); } path = "Assets" + path; string meshPath = path + "Mesh.asset";// folder + "/" + seed.gameObject.name + "Mesh.asset"; Mesh newMesh = Object.Instantiate <Mesh>(seed.Mesh); AssetDatabase.CreateAsset(newMesh, meshPath); if (!bMeshOnly) { string prefabPath = path + ".prefab"; GameObject newPrefab = PrefabUtility.CreatePrefab(prefabPath, seed.gameObject, ReplacePrefabOptions.ReplaceNameBased); newPrefab.GetComponent <ImplicitSurfaceMeshCreaterBase>().Mesh = newMesh; Selection.activeObject = newPrefab; } else { Selection.activeObject = newMesh; } AssetDatabase.SaveAssets(); }
protected void CreateGenerator() { GameObject prefab = Resources.Load("MeshGenerator") as GameObject; if (prefab != null) { GameObject g = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject; g.name = name + " Mesh Generator"; generator = g.GetComponent <ImplicitSurfaceMeshCreaterBase>(); generator.gridSize = 1f + 0.5f / quality; generator.powerThreshold = 0.4f * quality; root = g.transform.FindChild("RootNode"); } else { Debug.LogWarning("Couldn't load MeshCreator prefab"); } }
void Awake() { _surface = GetComponent <ImplicitSurfaceMeshCreaterBase> (); }
private void Awake() { this._surface = (ImplicitSurfaceMeshCreaterBase)((Component)this).GetComponent <ImplicitSurfaceMeshCreaterBase>(); }