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 zandegran · Sep 04, 2012 at 08:45 AM · texturebuildtexture2ddynamicvisible

My Dynamic texture not showing up in the Build???

**I have a texture which is working fine inside unity and it is not showing up after build??**I have attached the texture code..

 **

var sides:int=5; var treshold:int=170; var texturesize=512; var alphadecayrate=.01; private var color=Color.white;

 var rep=1;
 var spread=2;
 function Start () { 
 
     //renderer.material.shader = Shader.Find ("Transnalpha");
     renderer.material.shader = Shader.Find ("Diffuse");
    shade();
 }
 
 function Update () {
     
 }
 
 function shade ()
 {
 // Create a new 2x2 texture ARGB32 (32 bit with alpha) and no mipmaps
     var texture = new Texture2D(texturesize, texturesize, TextureFormat.ARGB32, false);
      var ii:int;
      var jj:int;
     // set the pixel values
     
        for( ii=0;ii<texturesize;ii++)
     for( jj=0;jj<texturesize;jj++)
     texture.SetPixel(ii, jj, Color(0, 0, 0, 0));
     
     var angle=Mathf.PI*2/sides;
 
     var radius=texturesize/2;
     var alf=((radius-1)-radius)/(treshold-radius);
     for (ii=0;ii<=radius;ii++)
     {
     var x:int;
      var y:int;
      if(ii>treshold)
      {
       color.a-=alphadecayrate;
       //print(alf);
      }
     for  (jj=1;jj<=sides+1;jj++)
     {
     
     var x1 = texturesize/2 + ii * Mathf.Sin(jj * angle);
     var y1 = texturesize/2 + ii * Mathf.Cos(jj * angle);
     if(x && y)
     {
     
     var w = x1 - x ;
     var h = y1 - y ;
     var dx1 = 0;var dy1 = 0;var dx2 = 0;var dy2 = 0 ;
     if (w<0) dx1 = -1 ; else if (w>0) dx1 = 1 ;
     if (h<0) dy1 = -1 ; else if (h>0) dy1 = 1 ;
     if (w<0) dx2 = -1 ; else if (w>0) dx2 = 1 ;
     var longest:int;
     longest = Mathf.Abs(w) ;
     var shortest = Mathf.Abs(h) ;
     if (!(longest>shortest)) {
         longest = Mathf.Abs(h) ;
         shortest = Mathf.Abs(w) ;
         if (h<0) dy2 = -1 ; else if (h>0) dy2 = 1 ;
         dx2 = 0 ;            
     }
     var numerator = longest >> 1 ;
     for (var i=0;i<=longest;i++) {
         texture.SetPixel(x, y, color);  //Put pixel
         texture.SetPixel(x, y+1, color);
         texture.SetPixel(x-1, y, color);
         numerator += shortest ;
         if (!(numerator<longest)) {
             numerator -= longest ;
             x += dx1 ;
             y += dy1 ;
         } else {
             x += dx2 ;
             y += dy2 ;
         }
     }
     
     //texture.SetPixel(x, y, Color(1.0, 1, 1, 200));
     }
     x=x1;
     y=y1;
     }
     
 }
     for(var kk=1;kk<=rep;kk++)
     for( ii=1;ii<texturesize-1;ii++)
     for( jj=1;jj<texturesize-1;jj++)
     {
     //texture.SetPixel(ii,jj,(texture.GetPixel(ii,jj)+texture.GetPixel(ii-1,jj)+texture.GetPixel(ii+1,jj)+texture.GetPixel(ii,jj-1)+texture.GetPixel(ii,jj+1)+texture.GetPixel(ii+1,jj+1)+texture.GetPixel(ii-1,jj-1)+texture.GetPixel(ii+1,jj-1)+texture.GetPixel(ii-1,jj+1))/9);
     texture.SetPixel(ii,jj,Color(texture.GetPixel(ii,jj).r,texture.GetPixel(ii,jj).g,texture.GetPixel(ii,jj).b,(texture.GetPixel(ii,jj).a+texture.GetPixel(ii-spread,jj).a+texture.GetPixel(ii+spread,jj).a+texture.GetPixel(ii,jj-spread).a+texture.GetPixel(ii,jj+spread).a+texture.GetPixel(ii+spread,jj+spread).a+texture.GetPixel(ii-spread,jj-spread).a+texture.GetPixel(ii+spread,jj-spread).a+texture.GetPixel(ii-spread,jj+spread).a)/9));
     }
     // Apply all SetPixel calls
     texture.Apply();
     
     // connect texture to material of GameObject this script is attached to
     renderer.material.mainTexture = texture; 
 }


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

0 Replies

· Add your reply
  • Sort: 

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

7 People are following this question.

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

Related Questions

Distribute terrain in zones 3 Answers

What are possible causes and solutions to randomly garbled textures on standalone builds? 1 Answer

Dynamically create Texture2D that is readable 2 Answers

How to add texture to a script and make the texture work in release build? 0 Answers

How to get player's face onto character mesh 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