- Home /
This question was
closed Dec 16, 2014 at 07:51 PM by
Graham-Dunnett for the following reason:
Duplicate Question
Error CS0029 CS0266
I made a Script called editor to let the player build their own spaceship.This script is not complete but it should let the player to chose Cabin_1-ex and than move it across the screen(kinda like drag and drop without dropping),but i get 2 errors CS0029 (30,17) and CS0266 (43,17).WHAT'S WRONG?
using UnityEngine;
using System.Collections;
public class Editor : MonoBehaviour {
public string pagename;
public int page = 1;
void OnGUI () {
GUI.Box (new Rect (10, 10, Screen.width / 4, Screen.height - 10), pagename);
if (page != 1) {
if (GUI.Button (new Rect (10, Screen.height - 30, 20, 20), "<")) {
page--;
}
}
if (page != 5) {
if (GUI.Button (new Rect ((Screen.width / 4) - 10, Screen.height - 30, 20, 20), ">")) {
page++;
}
}
if (page == 1)
pagename = "Cabins";
if (page == 2)
pagename = "Propulsion";
if (page == 3)
pagename = "Weapons";
if (page == 4)
pagename = "Structural";
if (page == 5)
pagename = "Utility";
if (GUI.Box(new Rect(20,20,Screen.width/8,Screen.height/8),"Cabin")){
Grab();
}
}
// Update is called once per frame
void Update () {
}
void Grab(){
GameObject part;
Vector3 pos = Input.mousePosition;
pos.z = transform.position.z - Camera.main.transform.position.z;
part = Resources.LoadAssetAtPath("Assets/Parts/Cabin_1-ex",typeof(GameObject));
part.transform.position = Camera.main.ScreenToWorldPoint(pos);
}
}
Comment
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Error In C# 1 Answer
Error code CS0029. 1 Answer
Instantiate object in world C# 3 Answers