Unity and Java Programming Question

I was wondering how I could use Java to program Unity 5.0.0. Here are some things I need to be able to do:

  1. Start the cutscene (it will start as soon as the program starts)
  2. Use music (from a file)
  3. Zoom in and out
  4. Hide/show entities at certain points
  5. Have the user enter text (the text must be saved as a variable) when the cutscene is paused
  6. Make text appear and disappear without the use of separate GUI’s
  7. End the cutscene

I also need to know how to import 3 dimensional files made from a different program.

No. Unity code is written in Javascript or C#.

Importing 3d models is trivial from FBX, OBJ, DAE, or Blend file formats.

I would prefer not to write someone else’s code, rather help debug or fix it. First of all, make sure you have a background in java or c# programming as Unity uses Javascript(not java) and c#. Just slight syntax differences.

1- To start your cutscene from the beginning, put any initializing scripts, start animations, coroutines, etc. in your Start() function.

2- Your music should be imported as any other asset. In your main script to control your cutscene scene, reference this script as a variable:

var yourVariableName: AudioClip;

This will create an option in the unity editor to reference this variable to an existing asset(your sound file).

3- To zoom in/out, add a rigidbody to your camera(found under physics section. It is a script). Then use

    transform.position = new Vector3(x , y , z);

4- To hide/show entities, use

    renderer.enabled = true or false(depending on the occasion); 

To access the renderer of an entity from your main script(if you intend on controlling everything from one script), you must reference your gameobject(the entity) by creating a variable to store it in(just like the audio clip)

        var yourVariableName: GameObject;

Then use

    yourVariableName.GetComponent(Renderer).enabled = true or false;

5- To obtain a string or int variable from the user during a pause/break in the cutscene(which can be paused with Time.timescale = 0 and put back to normal with Time.timescale = 1; Also, these don’t affect any OnGUI() functions so this works just fine) you must use the following code

    var showGui : boolean=false;
    var yourGameObjectStorer : GameObject;
    var userInput : string;
     
    //Call this function when you want to ask for the user's input
     public void ShowGUI()
     {
         Time.timeScale = 0;
         objectToStoreValueIn = yourGameObjectStorer; 
         showGUI= true;
     }
    void OnGUI()
     {
         if(showGUI)
         {
             userInput = GUI.TextField(new Rect(10, 10, 200, 20), userInput, 25);
             if (GUI.Button (new Rect (10,30,150,100), "Finish"))
                 StoreValues();
         }
     }
    
    void StoreValues()
     {
         objectToStoreValueIn.input = userInput;
         showGUI = false;
         Time.timeScale = 1;
     }

Your objectToStoreValueIn must have an “input” variable for this to work.

6- I’m not exactly sure what you mean by “seperate GUI’s” here, but here is how I would approach this problem.

    var GUITex1 : Texture;
    var GUITex2 : Texture;
    var GUITex3 : Texture;
    var show1 : boolean = false;
    var show2 : boolean = false;
    var show3 : boolean = false;
    
    void OnGUI()
     {
         if(show1)
         {
             GUI.DrawTexture(Rect (10,10,200,20), GUITex1);
         }
         if(show3)
         {
             GUI.DrawTexture(Rect (10,10,200,20), GUITex2);
         }
         if(show3)
         {
             GUI.DrawTexture(Rect (10,10,200,20), GUITex3);
         }
     }

Just turn on/off these booleans to show/hide the GUI textures.

7- To end the cutscene, there are multiple things you could do. The most plausible would be to load a small scene(so it loads very quickly to get out of the last frame of the cutscene) then use this scene to load your next real level. Maybe have a loading image here.

Application.LoadLevel("levelName");

As for the importing of 3d models, look for online tutorials for importing your 3d models with animations for your cutscene. These is quite easily done if you have blender. Unity automatically imports .blend files without exporting which keeps animations and materials.

Do you even Unity?
Also, you should try searching for answers before actually asking a question, there is bunch of tutorials on stuff you want. People here will not write code for you.