Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
gokofalse

Help me pls. :)

Question

Hi,

 

When I push G button on the keyboard, I want a picture to be on the screen.

 

How can I do that?

 

Could you send me the code? with "exit" button pls :)

Share this post


Link to post
Share on other sites

15 answers to this question

Recommended Posts

  • 0

Here you have but you should learn this by yourself(btw i didnt tested it but it should work).

Please login or register to see this code.

Share this post


Link to post
Share on other sites

  • 0

Please login or register to see this code. Please login or register to see this code.

DID NOT TEST I JUST MODIFIED "( THENEXT2 )" post

Edited by dacodecboy

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

Please login or register to see this link. How can we solve this problem? :)

Share this post


Link to post
Share on other sites
  • 0

Delete one of the = signs on public bool ButtonRelease == false; only supposed to be one

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

That's new one :) Please login or register to see this link.

 

When I deleted one of them, The project had 6 more wrongs :(

Share this post


Link to post
Share on other sites
  • 0

Instead of hunting for errors in other ppl's examples, use this and change ScriptName to the name of your c# script. Much shorter and much neater

public class ScriptName : MonoBehaviour

{

public Texture2D : image;

private bool : showImage;

void Update()

{

if(Input.GetKeyDown("g")) showImage = !showImage;

}

void OnGUI()

{

if(showImage) GUILayout.Label(image);

}

}

Oh and add your using crap at the top, forgot it bc I normally don't program in c#

Share this post


Link to post
Share on other sites
  • 0

Another question

 

Please login or register to see this link. How can I write here?

 

So, I want to write something on another line.

 

That's the code:

 

#pragma strict
 
var durdur : boolean = false;
 
 
function OnGUI(){
 
if(Input.GetKeyDown(KeyCode.G)){
durdur = true;
}
 
if(durdur == true){
 
GUI.Box(Rect(310,75,300,400), "Oyun Durduruldu");
 
if(GUI.Button(Rect(420,160,80,20),"Devam")){
durdur = false;
 
}
 
 
 
 
 
}
 
if (durdur == true){
Time.timeScale = 0;
}
 
if (durdur == false){
Time.timeScale = 1;
}
 
}

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

 

Please login or register to see this link. :(

 

There are also semicolones at the end of the lines :(

Share this post


Link to post
Share on other sites
  • 0

Are you using c# or js, on confused on why your posting both file types? U have to use one or the other

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

It does not matter :) C# or javascript :) Both of them can help me :)

I will use the script which works

Edited by gokofalse

Share this post


Link to post
Share on other sites
  • 0

There shouldn't be any errors if you put that code in a c# script and the using statements to the top

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

I have copied all of them and I created a .cs doc. If you want you can check it. 

 

Please login or register to see this link.

Edited by gokofalse

Share this post


Link to post
Share on other sites
  • 0

I can't view your links on iphone. .cs doc?havent heard it called a document in awhile. It shouldn't take this many replies to toggle a Boolean and show an image if true. There's 0 mistakes in my code beings it's literally lines of code. Then create a js and put this:

var image : Texture2D;

var isShowing : boolean;

function Update()

{

if(Input.GetKeyDown("g")) isShowing = !isShowing;

}

function OnGUI()

{

if(isShowing) GUILayout.Label(image);

}

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

 

This time it has worked :) In addition; How can I add an exit button ? 

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

 

on the OnGUI void/function

 

c# :

 

if (GUI.Button(new Rect(0,0,150,25),"Exit"))

{

Application.Quit();

}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...