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 /
avatar image
0
Question by mister.keith · Feb 19, 2013 at 06:23 AM · graphicswindowslinuxbuildsgl

GL Lines work on one platform, others, not so much

I am currently in the process to putting out a couple of builds of a project I am actively working on Independently. I will be deploying out to Linux, Windows and Mac. When I build out the game and send it to any Mac computers, no problems whatsoever. However, if all of my Windows and Linux players are experiencing the same problems. Here's whats going on.

I am using GL lines to turn things from a 3D mesh into a "wireframe" texture through javascript. Here is that code:

 var lineColor : Color;
 var backgroundColor : Color;
 var ZWrite = true;
 var AWrite = true;
 var blend = true;
 
 private var lines : Vector3[];
 private var linesArray : Array;
 private var lineMaterial : Material;
 private var meshRenderer : MeshRenderer;
 
 
 public function Start ()
 {
     meshRenderer = GetComponent(MeshRenderer);
     if(!meshRenderer) meshRenderer = gameObject.AddComponent(MeshRenderer);
     meshRenderer.material = new Material("Shader \"Lines/Background\" { Properties { _Color (\"Main Color\", Color) = (1,1,1,1) } SubShader { Pass {" + (ZWrite ? " ZWrite on " : " ZWrite off ") + (blend ? " Blend SrcAlpha OneMinusSrcAlpha" : " ") + (AWrite ? " Colormask RGBA " : " ") + "Lighting Off Offset 1, 1 Color[_Color] }}}");
     lineMaterial = new Material("Shader \"Lines/Colored Blended\" { SubShader { Pass { Blend SrcAlpha OneMinusSrcAlpha ZWrite Off Cull Front Fog { Mode Off } } } }");
     lineMaterial.hideFlags = HideFlags.HideAndDontSave;
     lineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
 
     linesArray = new Array();
     var filter : MeshFilter = GetComponent(MeshFilter);
     var mesh = filter.mesh;
     var vertices = mesh.vertices;
     var triangles = mesh.triangles;
 
     for (i = 0; i < triangles.length / 3; i++)
     {
         linesArray.Add(vertices[triangles[i * 3]]);
         linesArray.Add(vertices[triangles[i * 3 + 1]]);
         linesArray.Add(vertices[triangles[i * 3 + 2]]);
     }
     lines = linesArray.ToBuiltin(Vector3);
 }

 public function OnRenderObject()
 
 {   
     meshRenderer.material.color = backgroundColor;
     lineMaterial.SetPass(0);
     GL.PushMatrix();
     GL.MultMatrix(transform.localToWorldMatrix);
     GL.Begin(GL.LINES);
     GL.Color(lineColor);
 
     for (i = 0; i < lines.length / 3; i++)
     {
         GL.Vertex(lines[i * 3]);
         GL.Vertex(lines[i * 3 + 1]);
         GL.Vertex(lines[i * 3 + 1]);
         GL.Vertex(lines[i * 3 + 2]);
 
         GL.Vertex(lines[i * 3 + 2]);
         GL.Vertex(lines[i * 3]);
     }
 
     GL.End();
     GL.PopMatrix();
 
 }

When used on a Windows or Linux machine none of the lines rendered appear the color they are supposed to be. I know they are being drawn but the color is black not the color in the inspector (green, white, etc.) Any idea where to even begin?

EDIT: I looked a little further and testedout my builds and it looks like the mesh.renderer.material works, its just the lines that aren't being put into the colors specified. This led me to start looking at OnRenderObject() to make sure that was working up to snuff. Thoughts?

Comment
Add comment · Show 2
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 robertbu · Feb 19, 2013 at 08:54 PM 1
Share

Shot in the dark: Have you verified that the shader you use for your material works the same on all platforms? $$anonymous$$ight also try using a pre-created material rather than a new $$anonymous$$aterial().

avatar image mister.keith · Feb 19, 2013 at 09:17 PM 0
Share

I watched what the script does to the shader ( I tried in a couple different shaders for testing purposes) and it replaces it with a shader that is created on the fly called Lines/Background. I have a feeling it's not compatible with Windows / Linux. I was actually about to try a pre material. I'll update with results.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by carterCook · Jan 19, 2016 at 08:32 AM

I found that creating a new material via code shows up in the player, but not in the windows build. I used a material from the editor instead, and then it worked in the build :)

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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

Why does my game run much faster on Windows than Linux 1 Answer

Is using Unity a viable way to create cross-platform screensavers? 0 Answers

Linux-export: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.14' not found 2 Answers

Dual Webcams work under Windows but not Linux 2 Answers

Graphics library 1 Answer


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