Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Mar 04, 2014 at 01:36 PM by z3nth10n for the following reason:

Solved

avatar image
0
Question by z3nth10n · Mar 04, 2014 at 02:32 AM · editorbuildrenderminimap

Graphics.DrawTexture() not rendering on builded game (but it renders on Editor)

Hi,

I have a problem with my Minimap that I created few months ago with that tutorial. I edited it two days ago with a little script that zoom it out and in. For some reason when I build my game, the minimap doesn't render....

EDIT: I realised that a mini HUD that I have in my inventory doesn't render... So I change the title to Graphics.

The code I use:

 //Options menu, the menu options is there:

 private static float _minimapZoom;

 public static float MinimapZoom {
     get {return _minimapZoom;}
     set {_minimapZoom = value;}
 }
 
 void OnGUI() {
 
 if(Minimap) {
 
             if (style != "menu") {
                 GUI.DrawTexture(new Rect(Screen.width/2-350, Screen.height/2-252, 700, 525), preTab);
             }
             
             string MinimapStr = "";
             
             if(MinimapZoom >= 30 && MinimapZoom < 100) {
                 MinimapStr = "x16";
             } else if(MinimapZoom >= 100 && MinimapZoom < 200) {
                 MinimapStr = "x8";
             } else if(MinimapZoom >= 200 && MinimapZoom < 400) {
                 MinimapStr = "x4";
             } else if(MinimapZoom >= 400 && MinimapZoom < 600) {
                 MinimapStr = "x2";
             } else if(MinimapZoom >= 600 && MinimapZoom < 800) {
                 MinimapStr = "x1";
             } else if(MinimapZoom >= 800) {
                 MinimapStr = "x0.5";
             }
             
             GUI.Label(new Rect(MarginW-300, MarginH-287+50, 300, 30), "Zoom del Minimapa: " + MinimapStr);
             
             MinimapZoom = GUI.HorizontalSlider(new Rect(MarginW-300, MarginH-287+75, 300, 20), MinimapZoom, 30, 1000);
             
             if(GUI.Button(new Rect(MarginW-100, MarginH-287+75+515-95, 200, 50), "Hecho")) {
                 ApplyChanges();
                 Minimap = false;
                 MenuStart = true;
             }
 
         }
 
 }



Apply changes:

     private static void ApplyChanges() {
 
         //Var != 0 is for avoid bugs
 
         if (FOV != 0) {
             INI_Manager.Set_Value (Application.dataPath + "/appConfig.cfg", "FOV", Convert.ToString (FOV));
         }
 
         if (Sensibility != 0) {
             INI_Manager.Set_Value (Application.dataPath + "/appConfig.cfg", "Sensibility", Convert.ToString (Sensibility));
         }
 
         if(Brightness != 0) {
             INI_Manager.Set_Value (Application.dataPath + "/appConfig.cfg", "Brightness", Convert.ToString(Brightness));
         }
 
         if(RenderDistance != 0) {
             INI_Manager.Set_Value (Application.dataPath + "/appConfig.cfg", "RenderDistance", Convert.ToString(RenderDistance));
         }
 
         if (MaxFPS != 0) {
             INI_Manager.Set_Value (Application.dataPath + "/appConfig.cfg", "MaxFPS", Convert.ToString (MaxFPS));
         } else if (MaxFPS < 10) {
             INI_Manager.Set_Value (Application.dataPath + "/appConfig.cfg", "MaxFPS", "-1");    
         }
 
         INI_Manager.Set_Value (Application.dataPath + "/appConfig.cfg", "InvertMouse", Convert.ToString(Convert.ToInt32(InvertMouse)));
 
         if (MinimapZoom != 0) {
             INI_Manager.Set_Value (Application.dataPath + "/appConfig.cfg", "MinimapZoom", Convert.ToString (MinimapZoom));    
         }
 
         ReadValues();
         
     }



Read all the values again:

     private static void ReadValues() {
 
         GameGUI.GUIOptions.SetSensivity (InvertMouse, Sensibility);
 
         Camara.fieldOfView = FOV;
         Camara.farClipPlane = RenderDistance;
         
         RenderSettings.ambientLight = new Color(Brightness, Brightness, Brightness, 1.0f);
 
     }


The function that set the camera position

 //The player system class
 
     public static void MiniMap(GameObject player, float seg) {
 
         Camera.minimap.transform.position = new Vector3(player.transform.position.x, player.transform.position.y + seg, player.transform.position.z);
 
     }



Player script attached to the scene:

 public class PlayerSystemindex : MonoBehaviour {
 
 ...
 
 GameObject player = ....
 
 void Update() {
 
 PlayerSystem.MiniMap(player, Options.MinimapZoom);
 
 }
 
 }



Rendering on GUI:

 //And render it on the GUI... (As the tutorial said)
             
 void OnGUI() {
 
 if(Event.current.type == EventType.Repaint) {
                 Graphics.DrawTexture (new Rect (Screen.width - 215, 61, 150, 150), minimapTexture, minimapMaterial);
             }
 
 }

Builded game:

Builded game

Editor game:

Editor

And a few images of how I set everything...

Minimap camera

PD: I don't have any script on it. And I test to change everything on the cam, and in the script (like setting manual y-coords, displayig the game in full screen and in windows version, etc)

What can be wrong??


Sometimes when I change the VSync the map dissapear (on Editor too), because I have a class that was changed and I put it at the start of anything that loads everything:

 using UnityEngine;
 using System.Collections;
 
 public class MainThread : MonoBehaviour {
 
     void Awake() {
         
         //Set all the values at start
         Options.SetValues();
         
         QualitySettings.vSyncCount = Options.VSync;
         Application.targetFrameRate = (int)Options.MaxFPS;
         
     }
 
 }



Set values:

     public static void SetValues() {
 
         preTab = (Texture2D)Resources.Load ("images/preTab2");
 
         FOV = float.Parse(INI_Manager.Load_Value(Application.dataPath + "/appConfig.cfg", "FOV"));
         Sensibility = float.Parse(INI_Manager.Load_Value(Application.dataPath + "/appConfig.cfg", "Sensibility"));
         RenderDistance = float.Parse(INI_Manager.Load_Value(Application.dataPath + "/appConfig.cfg", "RenderDistance"));
         MaxFPS = float.Parse(INI_Manager.Load_Value(Application.dataPath + "/appConfig.cfg", "MaxFPS"));
         VSync = Convert.ToInt32(INI_Manager.Load_Value (Application.dataPath + "/appConfig.cfg", "VSync"));
         InvertMouse = Convert.ToBoolean(Convert.ToInt32(INI_Manager.Load_Value(Application.dataPath + "/appConfig.cfg", "InvertMouse")));
         Brightness = float.Parse(INI_Manager.Load_Value (Application.dataPath + "/appConfig.cfg", "Brightness"));
         MinimapZoom = float.Parse(INI_Manager.Load_Value (Application.dataPath + "/appConfig.cfg", "MinimapZoom"));
 
         //That is for set default values if the app is bugged
 
         if (FOV == 0 || FOV == null) {
             FOV = 60;        
         }
 
         if (Sensibility == 0 || Sensibility == null) {
             Sensibility = 15;        
         }
 
         if (RenderDistance == 0 || RenderDistance == null) {
             RenderDistance = 1000;        
         }
 
         if (MaxFPS == 0 || MaxFPS == null) {
             Brightness = 0.3f;        
         }
 
         if (VSync == null || VSync == null) {
             VSync = 1;        
         }
 
         if (InvertMouse == null) {
             InvertMouse = false;        
         }
 
         if (MinimapZoom == 0 || MinimapZoom == null) {
             MinimapZoom = 100;
         }
 
         ReadValues();
 
     }

  

It can be too the Event?

I don't use any plaform dependant compilation on this part of the code. (I use it in other parts)


Maybe, its a Bug?? http://answers.unity3d.com/questions/389054/guidrawtexture-shows-in-unity-but-not-in-build.html

Thanks in advance. Bye.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

  • Sort: 
avatar image
0
Best Answer Wiki

Answer by z3nth10n · Mar 04, 2014 at 01:10 PM

And yes! This is a damn bug, I fix it after reading 3 post about that,

http://forum.unity3d.com/threads/128545-Graphics-DrawTexture-not-working-in-Standalone-Player

http://answers.unity3d.com/questions/389054/guidrawtexture-shows-in-unity-but-not-in-build.html

And finally the solution:

http://forum.unity3d.com/threads/132696-How-to-make-a-2D-Shader-works-with-OnGUI()-through-Graphics-DrawTexture()

You have to write on yours sub-shader that:

 SubShader
     {
         Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
         Lighting Off
         Cull Off
         ZTest Always
         ZWrite Off
         Fog { Mode Off }

And you will fix it!

Bye.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fabio1955 · Mar 04, 2014 at 01:16 PM 0
Share

The strange: this is not necessary with a NVidia Card only A$$anonymous$$D!

avatar image z3nth10n · Mar 04, 2014 at 01:24 PM 0
Share

I'm special and I use Intel... ;) xD ($$anonymous$$aybe it's ????? )

avatar image
0

Answer by fabio1955 · Mar 04, 2014 at 01:06 PM

I have already met this problem on a AMD card. I found a solution here: http://varuagdiary.blogspot.it/2012_01_01_archive.html.

The trick is to take off the alpha layer of the render texture during postrender. It works!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Materials breaking in built project (but not in editor play mode) 0 Answers

Distribute terrain in zones 3 Answers

Shader does not display properly in game/editor view, but building it works. 0 Answers

Grass (terrain detail mesh) show in editor, not in build 3 Answers

Render layers differing between Editor and Build 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges