/// <summary> /// Setup map renderer. /// </summary> void Awake() { if (fow.textureSize < 200) { fow.textureSize = 200; } if (miniMap == null) { miniMap = GameObject.FindObjectOfType(typeof(UIMiniMapBase)) as UIMiniMapBase; } if (worldMap == null) { worldMap = GameObject.FindObjectOfType(typeof(UIWorldMapBase)) as UIWorldMapBase; } //Holoville.HOTween.HOTween.Init(false, true, true); //Holoville.HOTween.HOTween.EnableOverwriteManager(false); if (Application.isPlaying) { if (mapTexture != null) { NJGTools.Destroy(mapTexture); } if (generateAtStart) { GenerateMap(); } } }
void OnDestroy() { if (Map.miniMap != null) { Map.miniMap.material.mainTexture = null; } if (Map.worldMap != null) { Map.worldMap.material.mainTexture = null; } if (NJGMap.instance.mapTexture != null) { NJGTools.Destroy(NJGMap.instance.mapTexture); } NJGMap.instance.mapTexture = null; }
void Awake() { map = NJG.NJGMapBase.instance; if (map == null) { Debug.LogWarning("Can't render map photo. NJGMiniMap instance not found."); NJGTools.Destroy(gameObject); return; } if (gameObject.GetComponent <Camera>() == null) { gameObject.AddComponent <Camera>(); } camera.useOcclusionCulling = false; Render(); }
/// <summary> /// Clean up. /// </summary> void OnDestroy() { //if (mapRenderer != null) // if (mapRenderer.gameObject != null) // NJGTools.Destroy(mapRenderer.gameObject); if (UIMiniMapOnGUI.instance != null && Application.isPlaying) { UIMiniMapOnGUI.instance.planeRenderer.material.mainTexture = null; } if (mapTexture != null) { NJGTools.Destroy(mapTexture); } mapTexture = null; //base.OnDestroy(); }
/// <summary> /// Setup map renderer. /// </summary> void Awake() { if (NJGMap.instance.fow.textureSize < 200) { NJGMap.instance.fow.textureSize = 200; } //Holoville.HOTween.HOTween.Init(false, true, true); //Holoville.HOTween.HOTween.EnableOverwriteManager(false); if (Application.isPlaying) { if (NJGMap.instance.mapTexture != null) { NJGTools.Destroy(NJGMap.instance.mapTexture); } if (NJGMap.instance.generateAtStart) { NJGMap.GenerateMap(); } } }
/// <summary> /// Clean up. /// </summary> void OnDestroy() { //if (mapRenderer != null) // if (mapRenderer.gameObject != null) // NJGTools.Destroy(mapRenderer.gameObject); if (UIMiniMap.instance != null) { UIMiniMap.instance.material.mainTexture = null; } if (UIWorldMap.instance != null) { UIWorldMap.instance.material.mainTexture = null; } if (mapTexture != null) { NJGTools.Destroy(mapTexture); } mapTexture = null; //base.OnDestroy(); }
/// <summary> /// Redraw the map's texture. /// </summary> public void Render() { if (map == null) { map = NJGMap.instance; } if (Time.time >= lastRender) { #if UNITY_EDITOR if (Application.isPlaying) { cam.targetTexture = null; lastRender = Time.time + 1f; } #endif mReaded = false; mApplied = false; mGenerated = false; mWarning = false; if (!map.optimize) { canRender = true; } if (map.mapSize.x == 0 || map.mapSize.y == 0) { map.mapSize = new Vector2(Screen.width, Screen.height); } if (map.generateMapTexture) { if (map.userMapTexture != null) { NJGTools.Destroy(map.userMapTexture); map.userMapTexture = null; } /*if (map.mapTexture != null) * { * NJGTools.DestroyImmediate(map.mapTexture); * map.mapTexture = null; * }*/ if (map.mapTexture == null) { mSize = map.mapSize; if (map.mapResolution == NJGMap.Resolution.Double) { mSize = map.mapSize * 2; } map.mapTexture = new Texture2D((int)mSize.x, (int)mSize.y, (TextureFormat)map.textureFormat, map.generateMipmaps); map.mapTexture.name = "_NJGMapTexture"; map.mapTexture.filterMode = map.mapFilterMode; map.mapTexture.wrapMode = map.mapWrapMode; lastSize = mSize; } } else if (!Application.isPlaying) { if (map.mapTexture != null) { NJGTools.DestroyImmediate(map.mapTexture); map.mapTexture = null; } //if (map.userMapTexture != null) //{ map.userMapTexture = new Texture2D((int)map.mapSize.x, (int)map.mapSize.y, (TextureFormat)map.textureFormat, map.generateMipmaps); map.userMapTexture.name = "_NJGTempTexture"; map.userMapTexture.filterMode = map.mapFilterMode; map.userMapTexture.wrapMode = map.mapWrapMode; //} } ConfigCamera(); cam.enabled = true; if (!Application.isPlaying) { cam.Render(); } } }