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 darkcookie · Apr 10, 2012 at 07:07 AM · cameraguimovementdisable3dtext

how can I disable all camera movements trough GUI?

I made a play button and when clicked it has the option of 2 GUI ...1 to load game ....2 to start a new game... my question is how can I stop all camera movement when the play button is pressed....ohh and the script is attached to the 3d text and not the camera.

the script...(java)..

 // ***********************************************************************
 import System;
 import System.Xml;
 import System.Xml.Serialization;
 import System.IO;
 import System.Text;
 
 var shownewgame : boolean = false;
 var showback : boolean = false;
 var showcontinue : boolean = false;
 var levelToLoad : String;
 var soundhover : AudioClip;
 var beep : AudioClip;
 var QuitButton : boolean = false;
 //*************************************************************************
 private var _Save : Rect;
 private var _Load : Rect;
 
 private var _SaveMSG : Rect;
 private var _LoadMSG : Rect;
 
 //var _ShouldSave : boolean;
 //var _ShouldLoad : boolean;
 //var _SwitchSave : boolean;
 //var _SwitchLoad : boolean;
 private var _FileLocation : String;
 private var _FileName : String = "SaveData.xml";
 
 //public GameObject player;
 var player : GameObject;
 var playerName : String = "Default";
 
 var MyStyle : GUIStyle;
 
 private var myData : UserData;
 private var _data : String;
 
 private var VPosition : Vector3;
 //*******************************************************************************
 
 function Awake () { 
       // XML Save/Load path
       _FileLocation=Application.dataPath;
       
           
       // Creating something to store information into.
      myData=new UserData();
     }
 //*********************************************************************************
 
 function OnMouseEnter(){
 audio.PlayOneShot(soundhover);
 }
 function OnMouseUp(){
 animation.CrossFade("PlayButtonAnimation");
 audio.PlayOneShot(beep);
 yield new WaitForSeconds(0.1);
 if(QuitButton){
 Application.Quit();
 }
 shownewgame = true;
 showcontinue = true;
 showback = true;
 
 }  
 
 function Update(){}
 
 function OnGUI(){
 if(shownewgame == true){
     if(GUI.Button(Rect(0,40,200,30),"New Game")){
        Application.LoadLevel(levelToLoad); //Code for new game button
     }
 }
 if(showcontinue == true){
                   
                    //code for continue button
      if(GUI.Button(Rect(0,80,200,30),"Continue")){
     
     GUI.Label(_LoadMSG,"Loading from: "+_FileLocation);
       // Load our UserData into myData
       LoadXML();
       if(_data.ToString() != "")
       {
          myData = DeserializeObject(_data);
          VPosition=new Vector3(myData._iUser.x,myData._iUser.y,myData._iUser.z);             
          player.transform.position=VPosition;
          curExperience = myData._iUser.experience;
          Debug.Log("Load Successful");
       }
     }
 }
 if(showback == true){
 if(GUI.Button(Rect(0,120,200,30),"Back")){
      showcontinue =false;
      shownewgame =false;
      showback =false;
 }
 }
 }
 //**********************************************************************************************
 
 //XML Code ************************************************************************************
 
 function UTF8ByteArrayToString(characters : byte[] )
 {     
    var encoding : UTF8Encoding  = new UTF8Encoding();
    var constructedString : String  = encoding.GetString(characters);
    return (constructedString);
 }
 
 
 function StringToUTF8ByteArray(pXmlString : String)
 {
    var encoding : UTF8Encoding  = new UTF8Encoding();
    var byteArray : byte[]  = encoding.GetBytes(pXmlString);
    return byteArray;
 }
    
 
 function SerializeObject(pObject : Object)
 {
    var XmlizedString : String  = null;
    var memoryStream : MemoryStream  = new MemoryStream();
    var xs : XmlSerializer = new XmlSerializer(typeof(UserData));
    var xmlTextWriter : XmlTextWriter  = new XmlTextWriter(memoryStream, Encoding.UTF8);
    xs.Serialize(xmlTextWriter, pObject);
    memoryStream = xmlTextWriter.BaseStream; // (MemoryStream)
    XmlizedString = UTF8ByteArrayToString(memoryStream.ToArray());
    return XmlizedString;
 }
 
 
 function DeserializeObject(pXmlizedString : String)   
 {
    var xs : XmlSerializer  = new XmlSerializer(typeof(UserData));
    var memoryStream : MemoryStream  = new MemoryStream(StringToUTF8ByteArray(pXmlizedString));
    var xmlTextWriter : XmlTextWriter  = new XmlTextWriter(memoryStream, Encoding.UTF8);
    return xs.Deserialize(memoryStream);
 }
 
 
 function CreateXML()
 {
    var writer : StreamWriter;
 
    var t : FileInfo = new FileInfo(_FileLocation+"/"+ _FileName);
    if(!t.Exists)
    {
       writer = t.CreateText();
    }
    else
    {
       t.Delete();
       writer = t.CreateText();
    }
    writer.Write(_data);
    writer.Close();
    Debug.Log("File written");
 }
    
 function LoadXML()
 {
    //StreamReader r = File.OpenText(_FileLocation+"\\"+ _FileName);
    var r : StreamReader = File.OpenText(_FileLocation+"/"+ _FileName);
    var _info : String = r.ReadToEnd();
    r.Close();
    _data=_info;
    Debug.Log("File Read");
 }
 
 //EndOfXML Code **************************************************************
 
 
 @script RequireComponent(AudioSource)
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
0
Best Answer

Answer by darkcookie · Apr 10, 2012 at 08:08 AM

i found the answer ......

 private var camMouse;
 
 function Start () {
 
 camMouse = gameObject.Find("Main Camera").GetComponent("MouseLook");
 
 } 
 function Update(){
 if (shownewgame == true){
 Screen.showCursor = !Screen.showCursor;
 Screen.showCursor = true;
 camMouse.enabled = !camMouse.enabled;
 }
 }
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 PandawanFr · Mar 15, 2015 at 04:07 PM 0
Share

Can anyone make this script in C#? Or at least tell me how I should declare cam$$anonymous$$ouse, as in your script, there is no property, it's just var cam$$anonymous$$ouse, while in C# I need something like GameObject cam$$anonymous$$ouse

avatar image darkcookie · Mar 15, 2015 at 09:17 PM 0
Share

You can declare it as a GameObject, Like this

  GameObject cam$$anonymous$$ouse = GameObject.Find("$$anonymous$$ain Camera");

to access it you can do something like this

 cam$$anonymous$$ouse.GetComponent<$$anonymous$$ouseLook>();

avatar image
1

Answer by Lttldude · Apr 10, 2012 at 07:56 AM

I'm not sure of the context of you script, but when the play button is pressed, you can grab the current position of the camera and store it in a variable. Then you can change a new variable called stopCamera to true. Then in the update function, a conditional statement will fix the camera's position to that Vector3. When you want it to stop fixing the camera's position, then make stopCamera false.

kind of like this:

 var fixedCameraPos : Vector3;
 var stopCamera : boolean = false;
 
 function Update() {
 if(stopCamera) {
 Camera.main.transform.position = fixedCameraPos;
 }
 }



Ideally you could stop the source of the camera's movement directly. How is the camera moving (following script, iTween, etc)?

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 darkcookie · Apr 10, 2012 at 08:05 AM 0
Share

thank you for the responce ...and i found the answer already thank you tho ...and its not moving ...only rotating ....its a 3d menu ..

avatar image Lttldude · Apr 10, 2012 at 08:10 AM 0
Share

ahhh that makes more sense. Good job.

avatar image darkcookie · Apr 10, 2012 at 08:58 AM 0
Share

no tnk you 4 taking time to help me :)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to handle FPSCharacter movement using Google daydream controller touchpad? 0 Answers

GUI box not moving with game object on X axis 0 Answers

how can i disable camera movement 1 Answer

Hide GUI while switchcam 3 Answers

Keeping an object constrained to a 2d radius based off of the camera 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