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 jchase520 · Jan 19, 2011 at 08:10 PM ·

C# Unity Script Examples & Question

I have a great book I'm reading for learning C# , my only problem is that I can't seem to find any scripts that are already done in C# that I can see why you need that initialize things under the void start , and do all your variables go in there or what?

Also a C# question here . I cant seem to find any where how many bytes are allocated when you declare a float or double.

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

2 Replies

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

Answer by Jesse Anders · Jan 19, 2011 at 09:14 PM

I didn't quite follow your question, but the Unity docs now have a 'language selection' option, so you should be able to find some examples there. (I think there are still some errors and oversights in the C# examples, but at least they're there now.) You can probably also find some C# scripts on the script Wiki.

As for your second question, IINM, the C# standard specifies 32 bits for floats and 64 bits for doubles. For more info, search for 'msdn c# float' and 'msdn c# double'.

[Edit: In reply to comment below.]

Here's a brief example of a C# script (not compiled or tested):

using UnityEngine;

public class MyClass : MonoBehaviour { // This is a public variable; as long as the type is // serializable, it'll show up in the inspector: public float myPublicVariable = 2f;

 // This is a private variable; it won't show up in
 // the inspector, and will only be accessible from
 // within the class:
 float myPrivateVariable = 10f;

 void Start()
 {
     // Just an example of accessing member variables:
     myPrivateVariable *= myPublicVariable;
 }

 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space)) {
         Debug.Log("Space was pressed");
     }
 }

}

Comment
Add comment · Show 5 · 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 jchase520 · Jan 19, 2011 at 09:29 PM 0
Share

no I've seen the C# code there , but none of those are a full working code , they only show how to use a certain function. I'm looking for a full script example that shows the same thing I see when I create a new C# script in $$anonymous$$ono

avatar image Jesse Anders · Jan 19, 2011 at 10:04 PM 0
Share

See edit above.

avatar image fireDude67 · Jan 19, 2011 at 11:19 PM 0
Share

$$anonymous$$ono == C# except $$anonymous$$ono is open source

avatar image _Petroz · Jan 20, 2011 at 01:41 AM 0
Share

Your private variable is public.

avatar image Jesse Anders · Jan 20, 2011 at 05:05 AM 0
Share

Oops, fixed....

avatar image
1

Answer by Meltdown · Jan 20, 2011 at 07:22 AM

Check out www.unity3dstudent.com

They have lots of script examples for doing certain things in Unity. The examples are in Javascript but on almost every lesson someone has posted the C# equivalent in the comments section.

After doing a few conversions from Javascript to C# you will be able to convert between the two eventually with ease.

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

No one has followed this question yet.

Related Questions

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

Temperature Script? 3 Answers

JS. error BCE0043 unexpected token 2 Answers

(script) how to get terrain to turn into blocks 0 Answers

Rotating my mesh towards other mesh 0 Answers


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