public void SetMapMagicInstance() { if (MapMagic.MapMagic.instance != null) { mapMagicInstance = MapMagic.MapMagic.instance; } else { mapMagicInstance = FindObjectOfType <MapMagic.MapMagic>(); } importDetails = true; importTrees = true; importObjects = true; _selectAllPrefabs = true; }
private void OnDrawGizmos() { MapMagic.MapMagic mm = MapMagic.MapMagic.instance; float size = mm.terrainSize; Vector3 cubeSize = new Vector3( size * transform.localScale.x, mm.terrainHeight * transform.localScale.y, size * transform.localScale.z ); Vector3 position = new Vector3( Offset.x + cubeSize.x / 2.0f, MapMagic.MapMagic.instance.transform.position.y + mm.terrainHeight / 2.0f * transform.localScale.y, Offset.z + cubeSize.z / 2.0f ); Gizmos.DrawWireCube(position, cubeSize); }
void Update() { MapMagic.MapMagic mm = MapMagic.MapMagic.instance; // Adjust transform to valid stamper coords transform.localScale = new Vector3( transform.localScale.x, Mathf.Clamp(transform.localScale.y, 0, 1), transform.localScale.x); float y = MapMagic.MapMagic.instance.transform.position.y + mm.terrainHeight * transform.localScale.y; if (y != transform.position.y) { transform.position = new Vector3(transform.position.x, y, transform.position.z); } }
public void Generate() { MapMagic.MapMagic mm = MapMagic.MapMagic.instance; Vector2 offset = new Vector2(Offset.x, Offset.z); float scale = transform.localScale.x; float intensity = transform.localScale.y; if (null != Generator && (offset != Generator.offset || scale != Generator.scale || intensity != Generator.intensity)) { Debug.Log("Generating..."); Generator.offset = offset; Generator.scale = scale; Generator.intensity = intensity; mm.ClearResults(Generator); mm.Generate(true); } }
public void SetMapMagicInstance() { #if UNITY_EDITOR Undo.RecordObject(this, "GPUI Set Map Magic Instance"); #endif if (MapMagic.MapMagic.instance != null) { mapMagicInstance = MapMagic.MapMagic.instance; } else { mapMagicInstance = FindObjectOfType <MapMagic.MapMagic>(); } importDetails = true; importTrees = true; importObjects = true; _selectAllPrefabs = true; }
public override void OnInspectorGUI() { MapMagic.MapMagic mm = MapMagic.MapMagic.instance; int index = 0; var names = new List <string>(); var stampers = new List <MapMagicStamperGenerator>(); foreach (var gen in mm.gens.list) { if (gen is MapMagicStamperGenerator) { MapMagicStamperGenerator mgs = gen as MapMagicStamperGenerator; if (gen == stamper.Generator) { index = names.Count; } names.Add(mgs.texture.name); stampers.Add(mgs); } } if (stampers.Count > 0) { index = EditorGUILayout.Popup(index, names.ToArray()); if (stampers[index] != stamper.Generator) { stamper.Generator = stampers[index]; } if (null != stamper.Generator) { stamper.Generator.offset = EditorGUILayout.Vector2Field("Offset", stamper.Generator.offset); stamper.Generator.intensity = EditorGUILayout.FloatField("Height", stamper.Generator.intensity * mm.terrainHeight) / (float)mm.terrainHeight; } } }