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.

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");

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.