- Home /
"Talking system" whhy when I build all destroy?
Hello,
its my first post on this forum, so I want to greeting with all of us.
I'm creating "Game" on my ingeener project for school, and I have a small problem.
I create: collecting cash and stars system and all work well.
I start create "Talking" Script too and when I done, all work well.
Problem's show, when i using button " build & run ", and:
At start console show me new errors, but on this forum i find resolve.
" if u have this error, in hierarhy do CTRL + A , DELETE, and CTRL + V" All ok i done it, all scipts r in self possition. I Start second time.. and ? And northing ! Unity3d ignore my script, don't do northing, and consolwe dont write any errors.
I start new project, write all from new.. and i have same problem , but before compile all work well ;S
It's my code script's for it:
intera.cs :
Code:
using UnityEngine;
using System.Collections;
public class intera : MonoBehaviour {
private GameObject ply ;
private GameObject cam;
public GUIText target;
private bool selected =false;
private bool menu =false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
renderer.material.color=Color.white;
selected = false;
}
public void OnLookEnter(){
renderer.material.color=Color.red;
target.text ="Nacisnij E by porozmawiac";
selected = true;
}
void OnGUI(){
ply = GameObject.Find("First Person Controller");
cam = GameObject.Find("Main Camera");
Event e = Event.current;
if(e.isKey && e.character == 'e' && selected ){
//rigidbody.AddForce(Vector3.up*100);
ply.GetComponent<MouseLook>().enabled = false;
ply.GetComponent<CharacterMotor>().enabled = false;
ply.GetComponent<FPSInputController>().enabled = false;
cam.GetComponent<MouseLook>().enabled = false;
Screen.showCursor = true;
menu = true;
}
if(menu){
GUI.Box(new Rect(0, (Screen.height/3)*2,Screen.width, Screen.height/3), " Dialog Test");
target.enabled = false;
if(GUI.Button(new Rect((Screen.width/2)-25,(Screen.height/4)*3, 50, 30), "Talk")){
ply.GetComponent<MouseLook>().enabled = true;
ply.GetComponent<CharacterMotor>().enabled = true;
ply.GetComponent<FPSInputController>().enabled = true;
cam.GetComponent<MouseLook>().enabled = true;
Screen.showCursor = false;
menu = false;
target.enabled = true;
}
}
}
}
selec.cs
Code:
using UnityEngine;
using System.Collections;
public class selec : MonoBehaviour {
public RaycastHit hit;
// Use this for initialization
void Awake () {
Screen.showCursor = false;
}
void Start () {
}
// Update is called once per frame
void Update () {
Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width/2, Screen.height/2, 0));
if(Physics.Raycast(ray, out hit, 10)){
if(hit.collider.gameObject.GetComponent<intera>() !=null ){
hit.collider.gameObject.GetComponent<intera>().OnLookEnter();
}
}
}
}
poup.cs
Code:
using UnityEngine;
using System.Collections;
public class poup : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
guiText.text ="";
}
}
Any1 could help me ?
OFC after resolve my problem, if any1 want to use this script, should feel free.
What I do bad?
Why when i do " play button " all works well but when i compile and run, all destroy.
P.S.
Stars, and cash script work well all time, after Build and before Build.
thx
Michal
Your answer
Follow this Question
Related Questions
Zombie Round Script Help 1 Answer
Spawn Script Not Working 1 Answer
[SOLVED] Problem with "foreach". 1 Answer
Bullet not moving 1 Answer
mistake in script 1 Answer