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 firasdeep · Oct 19, 2011 at 04:30 PM · convertconversion

Help...convert C# to Js ???

Hello

I try to convert it but doesn't work.. Any help>>>>

using UnityEngine;

using System.Collections;

using System.Collections.Generic;

public class Test5 : MonoBehaviour {

 public List<Transform> targets;

 // Use this for initialization

 void Start () {

     targets = new List<Transform>();

     AddAllenmey ();

 }

 public void AddAllenmey ()

 {

     GameObject[] go = GameObject.FindGameObjectsWithTag("wall");

     

     foreach(GameObject wall in go)

     {

         AddTarget(wall.transform);    

     }

     

 }

 public void AddTarget(Transform wall)

 {

     targets.Add(wall);    

 }

 // Update is called once per frame

 void Update () {

     

 }

}

Comment
Add comment · Show 1
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 syclamoth · Oct 19, 2011 at 04:30 PM 0
Share

I don't understand. Why would you ever want to to that?

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by jahroy · Oct 20, 2011 at 07:20 AM

The best way to learn would be to do it yourself, not have other people do it for you.

I'll give you a few hints (that are well documented here, here, here, etc...):

  1. For javascript you use import System.IO instead of using System.IO (in javascript you don't use the term using at all).
  2. When you declare a function in javascript, you use the keyword function and you are not required to declare its return type. In other words, you would use function Start() in stead of void Start()
  3. In javascript there is no need to type : MonoBehaviour when you declare a class. Scripts written in javascript extend the MonoBehaviour class by default.
  4. There are a few other basic syntax differences that are highlighted by the script you've posted. I can't think of a better way for you to learn javascript than to discover them by reading some documentation... That's the best way to learn Unity!
  5. Good luck!
Comment
Add comment · Show 3 · 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
avatar image firasdeep · Oct 20, 2011 at 08:06 AM 0
Share

Thx..............

avatar image blitzen · Oct 20, 2011 at 03:53 PM 1
Share

In regards to #2: You can declare its return type, though you apparently don't have to:

function PlusOne(a:int):int{
    var result:int;
    result=a+1;
    return result;
}

I find it good practice to always declare its return type, for readability's sake and for catching incompatible-type errors further up the road that might occur when assigning its return value to some variable.

avatar image jahroy · Oct 20, 2011 at 04:35 PM 0
Share

Absolutely... You're right. Thanks.

You can explicitly declare the type of everything in Unity javacript, which is quite cool.

I do the same, but was trying to keep is brief and simple above.

I changed the wording of my answer :)

avatar image
1

Answer by roamcel · Oct 19, 2011 at 07:16 PM

Javascript and c# can exist simultaneously in the same project. Be sure that you actually need to convert this before facing the woes of learning a new language :)

Comment
Add comment · Show 2 · 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
avatar image firasdeep · Oct 20, 2011 at 07:02 AM 0
Share

But I want to know how I do this in Java Script>> I mean [Array] (GameObject)....

avatar image firasdeep · Oct 20, 2011 at 01:15 PM 0
Share

THX...........

avatar image
0

Answer by ScriptGirl · Oct 20, 2011 at 05:08 PM

There is a utility available specifically for this. I haven't tested it but here is the link: Online UnityScript/Javascript to C# converter

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

7 People are following this question.

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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

js to c# conversion 1 Answer

Help with conversion from javascript to c# 3 Answers

VMD motion to FBX anim 0 Answers

world to screen coordinates conversion 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