Foro de elhacker.net

Programación => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: Deadbeat12 en 27 Noviembre 2021, 20:57 pm



Título: Create c # background code or pass it from java
Publicado por: Deadbeat12 en 27 Noviembre 2021, 20:57 pm
Help, could you help me, I am new to programming and I need to make a moving background in unity c # and when this background is finished a completely new one is created and the previous one is eliminated and this action several times. I have the code in java but I don't know how to do it in Unity.



Codigo:
Código
  1. var scrollSpeed : float = 0.5;
  2.     var GradientOn : boolean = false;
  3.     var $$anonymous$$ainImageOn : boolean = true;
  4.     var WhiteOn : boolean = false;
  5.     var WhiteToBlackon  : boolean = false;
  6.     var texture : Texture;
  7.     var gradient : Texture;
  8.     var white : Texture;
  9.     var WhiteToBlacktex : Texture;
  10.     var offset : float;
  11.     var reset : float;
  12.  
  13.  
  14.  
  15.  
  16.     function Update ()
  17.     {
  18.         offset = reset += Time.deltaTime*scrollSpeed;
  19.  
  20.             renderer.material.SetTextureOffset ("_$$anonymous$$ainTex", Vector2(0,reset));
  21.             if(offset >= 1.00 && $$anonymous$$ainImageOn == true)
  22.             {
  23.                 reset=0;
  24.             Gradient();
  25.             $$anonymous$$ainImageOn = false;
  26.             GradientOn = true;
  27.  
  28.             }
  29.             else if (offset >= 0.66 && GradientOn == true)
  30.             {
  31.             reset=0;
  32.             White();
  33.             GradientOn = false;
  34.             WhiteOn = true;
  35.             }
  36.             else if (offset >= 1.00 && WhiteOn == true)
  37.             {
  38.                 reset=0;
  39.             WhiteToBlack();
  40.             WhiteOn=false;
  41.             WhiteToBlackon = true;
  42.             }
  43.             else if (offset >= 0.66 && WhiteToBlackon == true)
  44.             {
  45.                 reset=0;
  46.             $$anonymous$$ainImage();
  47.             WhiteToBlackon = false;
  48.             $$anonymous$$ainImageOn = true;
  49.             }
  50.     }
  51.  
  52.  
  53.     function $$anonymous$$ainImage()
  54.     {
  55.     renderer.material.mainTexture = texture;
  56.     renderer.material.mainTextureScale = Vector2(1,1);
  57.     }
  58.  
  59.     function Gradient()
  60.     {    
  61.     renderer.material.mainTexture = gradient;
  62.     renderer.material.mainTextureScale = Vector2(1,0.333);
  63.     }
  64.  
  65.     function White()
  66.     {
  67.     renderer.material.mainTexture = white;
  68.     renderer.material.mainTextureScale = Vector2(1,1);
  69.     }
  70.  
  71.     function WhiteToBlack()
  72.     {    
  73.     renderer.material.mainTexture = WhiteToBlacktex;
  74.     renderer.material.mainTextureScale = Vector2(1,0.333);
  75.     }


Título: Re: Create c # background code or pass it from java
Publicado por: Eternal Idol en 27 Noviembre 2021, 22:54 pm
Lo muevo al subforo correspondiente; este es un foro de habla hispana.


Título: Re: Create c # background code or pass it from java
Publicado por: Deadbeat12 en 27 Noviembre 2021, 23:05 pm
Gracias