public class SampleCustomHeader : MonoBehaviour
{
const float BUTTON_HEIGHT = 50.0f;
const string CUSTOM_HEADER_KEY_NAME = "custom_timestamp";
WebViewObject_webviewObject
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnGUI()
{
float h = Screen.height;
if (GUI.Button(new Rect(.0f, h - BUTTON_HEIGHT, Screen.width, BUTTON_HEIGHT), "check for request header"))
{
this._webviewObject = GameObject.Find("WebViewObject").GetComponent<WebViewObject>();
this._webviewObject.LoadURL("http://httpbin.org/headers");
}
h -= BUTTON_HEIGHT;
if (GUI.Button(new Rect(.0f, h - BUTTON_HEIGHT, Screen.width, BUTTON_HEIGHT), "add custom header"))
{
this._webviewObject = GameObject.Find("WebViewObject").GetComponent<WebViewObject>();
this._webviewObject.AddCustomHeader(CUSTOM_HEADER_KEY_NAME, System.DateTime.Now.ToString());
}
h -= BUTTON_HEIGHT;
if (GUI.Button(new Rect(.0f, h - BUTTON_HEIGHT, Screen.width, BUTTON_HEIGHT), "get custom header"))
{
this._webviewObject = GameObject.Find("WebViewObject").GetComponent<WebViewObject>();
Debug.Log("custom_timestamp is " + this._webviewObject.GetCustomHeaderValue(CUSTOM_HEADER_KEY_NAME));
}
h -= BUTTON_HEIGHT;
if (GUI.Button(new Rect(.0f, h - BUTTON_HEIGHT, Screen.width, BUTTON_HEIGHT), "remove custom header"))
{
this._webviewObject = GameObject.Find("WebViewObject").GetComponent<WebViewObject>();
this._webviewObject.RemoveCustomHeader(CUSTOM_HEADER_KEY_NAME);
}
h -= BUTTON_HEIGHT;
if (GUI.Button(new Rect(.0f, h - BUTTON_HEIGHT, Screen.width, BUTTON_HEIGHT), "clear custom header"))
{
this._webviewObject = GameObject.Find("WebViewObject").GetComponent<WebViewObject>();
this._webviewObject.ClearCustomHeader();
}
h -= BUTTON_HEIGHT;
}
}
那里出了什么问题?我没有写代码,但我真的需要它。我正在运行Unity 2020.3.5f1 Personal。我使用Notepad++作为C#编辑器。如果我删除它,则会出现更多错误。
错误在(18,5(:错误CS1519:类、结构或接口成员声明中的令牌"void"无效
第6行:
WebViewObject_webviewObject
我假设你(或其他人(忘记在_
前面加一个空格,在末尾加一个分号(;
(。