Search Unity

Please help to convert from Java Script to C#

Discussion in 'Scripting' started by milamila, Aug 25, 2019.

  1. milamila

    milamila

    Joined:
    Nov 21, 2013
    Posts:
    16
    Kindly ask to help to convert form Java Script to C# the script from this thread https://answers.unity.com/questions/381183/two-textures-on-one-surface.html

    And here is the script in Java. If anyone could help I will be desperately grateful.

    Code (JavaScript):
    1.  var tfLight: Transform;
    2. function Start () {
    3.      // find the revealing light named "RevealingLight":
    4.      var goLight = GameObject.Find("RevealingLight");
    5.      if (goLight) tfLight = goLight.transform;
    6. }
    7. function Update () {
    8.      if (tfLight){
    9.          renderer.material.SetVector("_LightPos", tfLight.position);
    10.          renderer.material.SetVector("_LightDir", tfLight.forward);
    11.      }
    12. }
    13.  
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,435
  3. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
  4. milamila

    milamila

    Joined:
    Nov 21, 2013
    Posts:
    16
    Thanks a lot!!
     
  5. Mg_82

    Mg_82

    Joined:
    Mar 4, 2021
    Posts:
    1
    // código-fonte JavaScript
    var AndarFrente: String;
    var AndarAtras: String;
    var RotacionarDireita: String;
    var RotacionarEsquerda: String;
    function Start () {
    }
    function Update () {
    }
    if (Input.GetKey (AndarFrente))
    {
    transform.rigidbody.velocity = transform.forward * 10;

    }
    if (Input.GetKey (AndarAtras))
    {
    transform.rigidbody.velocity = -transform.forward * 10;
    }
    if (Input.GetKey (RotacionarDireita))
    {
    transform.Rotate (0,90 * Time.deltaTime, 0);
    }
    if (Input.GetKey (RotacionarEsquerda))
    {
    transform.Rotate (0, -90 * Time.deltaTime, 0);
    }
    }


    alguem consegue converter para c#