Open DealPete opened 6 years ago
Install older Unity version.
This was pushed 3 years ago. Naturally the scripts won't be up-to-date. If you need help converting to the new Unity version I will be happy to help. If you are not already, I suggest using Visual Studio as Intellisense will greatly assist in fixing any deprecated function calls.
using UnityEngine;
using System.Collections;
public class UIctrl : MonoBehaviour { Resolution nowResolution;
public UIPopupList ResolutionPoplist;
public GameObject setting;
public UIToggle fullscreen;
int count;
void showSetting()
{
count = 0;
setting.SetActive(!setting.activeSelf);
if (setting.activeSelf)
{
getResolution();
getFullScreen();
getQuality();
}
}
void getResolution()
{
nowResolution = Screen.currentResolution;
ResolutionPoplist.items.Clear();
foreach (Resolution res in Screen.resolutions)
{
ResolutionPoplist.items.Add(res.width + "*" + res.height);
}
ResolutionPoplist.value = nowResolution.width + "*" + nowResolution.height;
}
void getFullScreen()
{
fullscreen.isChecked = Screen.fullScreen;
}
void setFullScreen()
{
Screen.fullScreen = fullscreen.isChecked;
}
QualityLevel nowQuality;
public UIPopupList QualityPoplist;
void getQuality()
{
nowQuality = (QualityLevel)QualitySettings.GetQualityLevel();
QualityPoplist.items.Clear();
for (int x = 0; x < 6;x++ )
{
QualityLevel q = (QualityLevel)x;
QualityPoplist.items.Add(q.ToString());
}
QualityPoplist.value = nowQuality.ToString();
}
void setQuality()
{
int cur=QualityPoplist.items.IndexOf(QualityPoplist.value);
QualitySettings.SetQualityLevel(cur);
}
void setResolution()//开始会被调用2次
{
if (count<2)//用来解决分辨一打开就会被调用
{
count++;
return;
}
Debug.Log("出现");
string[] sz = ResolutionPoplist.value.Split('*');
Screen.SetResolution(int.Parse(sz[0]), int.Parse(sz[1]), fullscreen.isChecked);
}
void exitGame()
{
Application.Quit();
}
}
6. Now its time to fix all of the Unity deprecated function calls. Visual Studio will tell you what is wrong and what to use, a little tedious, but you can fix the remaining issues in about 10-20 minutes.
Example:
void push() { animation["boxcampush"].speed = 1; animation.Play("boxcampush"); box.animation["boxopendoor"].speed = 1; box.animation.Play("boxopendoor");
}
This is going to throw errors on the animation portion due to the following UnityUpgradeable error:
CS0619 'Component.animation' is obsolete: 'Property animation has been deprecated. Use GetComponent
The corrected code would look something like this:
void push()
{
GetComponent
The more efficient way would be to declare a private Animation variable so you only have to call the GetComponent function once, for example:
private Animation myAnimation;
Then define it in the Start function:
myAnimation = GetComponent
Then use the myAnimation variable.
Hope this helps you out.
I can't run this because the scripts use deprecated APIs