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 jluponeage · Jun 07, 2015 at 08:13 PM · java

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.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by tanoshimi · Jun 07, 2015 at 08:16 PM

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

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

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 jluponeage · Jun 10, 2015 at 11:03 PM 0
Share

Then what program could I use?

avatar image SamTheT · Jun 11, 2015 at 01:06 AM 0
Share

what do you mean?

avatar image
0

Answer by Hazzanger · Jun 11, 2015 at 09:06 AM

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.

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
avatar image
0

Answer by SamTheT · Jun 11, 2015 at 01:07 AM

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.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

HighScore not updating when the game time is up... 1 Answer

Field of view 1 Answer

Communicate with Android native plugin 0 Answers

How to make Unity find JDK on my linux machine. 1 Answer

Left Click Once, Does An Action, Left Click Again, Does Another Action., 2 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