Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

C# to Java

Discussion in 'Scripting' started by abidshaikh, May 17, 2014.

  1. abidshaikh

    abidshaikh

    Joined:
    Apr 16, 2014
    Posts:
    7
    hi,

    anyone know how to i convert this following line to Java script.


    Code (csharp):
    1. float widthofBGObject = ((BoxCollider2D)collider).size.x;
    thanks.
     
  2. KyleOlsen

    KyleOlsen

    Joined:
    Apr 3, 2012
    Posts:
    237
    Code (csharp):
    1.  
    2. var widthofBGObject : float = ((BoxCollider2D)collider).size.x;
    3.  
     
  3. abidshaikh

    abidshaikh

    Joined:
    Apr 16, 2014
    Posts:
    7

    hi,

    thanks for the code, but I'm getting this 2 following errors

    this is my completed code.....


     
    Last edited: May 17, 2014
  4. SiegfriedCroes

    SiegfriedCroes

    Joined:
    Oct 19, 2013
    Posts:
    569
    Does this work?

    Code (csharp):
    1. var widthofBGObject : float = (collider as BoxCollider2D).size.x;