Вот смотрю урок по созданию меню и сохранению игры
урок
но когда все та как там написано и чуть чуть изменив написал unity кричит на много ошибок хотя все так как там написано и не знаю что делать
Code
using UnityEngine;
using System.Collections;
public class menu : MonoBehaviour {
public Rect NevGame;
public Rect Prodolgit;
public Rect SeveGames;
public Rect LoadGames;
public Rect Options;
public Rect Author;
public Rect Exit;
public Rect label;
public GUISkin guiSkin;
public Texture2D fon;
public string SceneNamesStart;
public bool isOptions;
public bool isMenu;
void OnGUI()
{
GUI.skin = guiSkin;
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), fon);
if(!isOptions){
GUI.Label(label, "Âåðñèÿ Alfa 0.01");
if(GUI.Button(NevGame, "Íîâàÿ èãðà")){
Application.LoadLevel(SceneNamesStart);
}
if(GUI.Button(Prodolgit, "Ïðîäîëæûòü")){
}
if(GUI.Button(SeveGames, "Çàãðóçèòü")){
}
if(GUI.Button(LoadGames, "Çàãðóçèòü")){
}
if(GUI.Button(Options, "Îïöèè")){
isOptions = true;
}
if(GUI.Button(Author, "Àâòîðû")){
}
if(GUI.Button(Exit, "Âûõîä â Windows")){
Application.Quit();
}
else{
if(GUI.Button(Exit, "+")){
QualitySettings.shadowDistance = 10;
}
if(GUI.Button(Exit, "-")){
QualitySettings.shadowDistance = 0;
}
if(GUI.Button(Exit, "back")){
isOptions = false;
}
}
}
}
}
второе меню
Code
using UnityEngine;
using System.Collections;
public class menu_inGmae : MonoBehaviour {
public Rect Prodolgit;
public Rect SeveGames;
public Rect LoadGames;
public Rect Options;
public Rect Exit;
public Rect label;
public GUISkin guiSkin;
public bool isOptions;
public bool isMenu;
void OnGUI()
{
GUI.skin = guiSkin;
if(isMenu){
if(!isOptions){
if(GUI.Button(Prodolgit, "Ïðîäîëæûòü")){
isMenu = false;
Time.timeScale = 1;
}
if(GUI.Button(SeveGames, "Seve")){
gameObject.SendMessage("Seve");
}
if(GUI.Button(LoadGames, "Load")){
gameObject.SendMessage("Load");
}
if(GUI.Button(Options, "Îïöèè")){
isOptions = true;
}
if(GUI.Button(Exit, "Âûõîä â Windows")){
Application.Quit();
}
else{
if(GUI.Button(Prodolgit, "+")){
QualitySettings.shadowDistance = 10;
}
if(GUI.Button(LoadGames, "-")){
QualitySettings.shadowDistance = 0;
}
if(GUI.Button(Exit, "back")){
isOptions = false;
}
}
}
}
}
void Update () {
if(Input.GetKeyUp(KeyCode.Escape)){
isMenu = true;
Time.timeScale = 0;
}
}
}
сохранение
Code
using UnityEngine;
using System;
using System.Collections;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Collections.Generic;
using System.Collections;
class PositionVarible{
public float positionX;
public float positionY;
public float positionZ;
}
public class SeveAedLoad : MonoBehaviour {
public void Save(){
PositionVarible pv = new PositionVarible();
pv.positionX = transform.position.x;
pv.positionY = transform.position.y;
pv.positionZ = transform.position.z;
FileStream file = new FileStream("Save.dat", FilterMode.Create);
BinaryFormatter binFor = new BinaryFormatter();
binFor.Serialize(file, pv);
}
public void Load(){
IFormatter If = new BinaryFormatter();
FileStream file = new FileStream("Save.dat", FilterMode.Open, FileAccess.Read);
PositionVarible pv2 = (PositionVarible)If.Deserialize(file);
transform.position = new Vector3(pv2.positionX, pv2.positionY, pv2.positionZ);
file.Close();
}
}
ошыбки