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 Mr_T · Jan 29, 2011 at 02:33 AM · build-errorvariablesgui-button

Button Script issue, works in game mode not in build and run

this script is on my button GUITexture

var rolloverTexture : Texture2D; var normalTexture : Texture2D; var noTexture : Texture2D; var Dragon : GameObject; static var thisGameStart : boolean = false;

 function OnMouseEnter(){
     if(thisGameStart==false){
     guiTexture.texture = rolloverTexture;
     }

 }
 function OnMouseExit(){
     if(thisGameStart==false){
     guiTexture.texture = normalTexture;
     }else{
         guiTexture.texture=noTexture;
     }
 }
 function OnMouseUp () {

         var TargetScript : DragonGameIntro = gameObject.GetComponent(DragonGameIntro);

         TargetScript.attack = true;

         thisGameStart = true;

         guiTexture.texture = noTexture;
 }

this script is on a dragon that circles until the button is clicked then moves toward the target located near the camera

static var attack : boolean = false; var MoveTarget : GameObject; var MoveTimer : float = 0; var emitter1 : GameObject; var emitter2 : GameObject; var emitter3 : GameObject; var light1 : GameObject;

 emitter1 = gameObject.Find("OuterCore");
 emitter2 = gameObject.Find("InnerCore");
 emitter3 = gameObject.Find("Smoke");
 light1 = gameObject.Find("Lightsource");

 var FireSound : AudioClip;

 function Update () {


     if(attack==false){

         gameObject.transform.Rotate(0,.5,0);
         gameObject.transform.Translate(0,0,.3);

         emitter1.particleEmitter.emit=false;
         emitter2.particleEmitter.emit=false;
         emitter3.particleEmitter.emit=false;
         light1.light.enabled=false;

     }

     if(attack==true){
         MoveTimer++;

         is_breathingfire=true;


         if(is_breathingfire==true){


             PlaySound(FireSound);

             emitter1.particleEmitter.emit=true;
             emitter2.particleEmitter.emit=true;
             emitter3.particleEmitter.emit=true;
             light1.light.enabled=true;

         }   


         transform.LookAt(MoveTarget.transform);
         transform.position = Vector3.Lerp(transform.position,MoveTarget.transform.position,Time.deltaTime * .6);
         var Dist : float = Vector3.Distance(transform.position,MoveTarget.transform.position);
         if(Dist<4){
             NextLevel();
         }

     }

 }


 function PlaySound(currentSound){

     audio.PlayOneShot(currentSound);

 }



 function NextLevel(){

             Application.LoadLevel("ValleyLevel");

 }   


 function gameStart(){

             attack=true;


     }

When I test it in game mode the button does the rollover and on MouseUp the dragon breathes fire and moves toward the target object. When I do build and run the rollover works but the dragon just stops wherever he happens to be, no flames, no Lerp, no level open.

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

1 Reply

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

Answer by Bunny83 · Jan 29, 2011 at 03:19 AM

I can't belive that your setup work, even in "game mode".

 var TargetScript : DragonGameIntro = gameObject.GetComponent(DragonGameIntro);

in this line you try to get a reference to the DragonGameInfo script. I guess, you didn't tell us the script names, your second script is the "DragonGameIntro" script and is attached to this dragon GameObject.
But you search for it on your GUITexture! I think you wanted do something like this:

 var TargetScript : DragonGameIntro = Dragon.GetComponent(DragonGameIntro);

You don't use the Dragon-GameObject-reference at the moment, so maybe you implemented it later and forgot to change it in that line.

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 Mr_T · Jan 29, 2011 at 03:49 PM 0
Share

Thanks, I was sure it was something stupid. I too am puzzled how it worked in game mode. The fact that it worked had me overlooking the obvious.

avatar image Bunny83 · Jan 30, 2011 at 12:50 AM 0
Share

Just another hint: If you create a windows build all Debug.Log will still logged but not in a console window like in the editor but to a text-file. The file is located in the data folder of your build and is called "output_log.txt". If there are errors like null-reference exceptions they will be logged into that file.

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

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

How can I stop the variable values reverting to its default values after being built? 1 Answer

Material/Shader issue 0 Answers

,Hololens Fail to resolve assembly WinRTLegacy 0 Answers

unity 5.6.2f1 64bit stuck at build 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