1

私は自分のプロジェクトを開始していますが、このエラーが発生しました。何が問題なのかわかりません。ばかげた質問である場合は、本当に助けに感謝し、申し訳ありません。私は団結でまだ新しいです。すべての答えをありがとう。

この vector2(width,height) に関するヘルプを検索してみましたが、私には問題ないようです。また、誰かがこのrect.centerの問題について私に説明できるなら、なぜ私はそれを手に入れたのですか?

Unity3d エラー:

Assets/Scenes/Game/Scripts/GUI/GameGUI.cs(22,22): error CS1061: Type `UnityEngine.Rect' does not contain a definition for `center' and no extension method `center' of type `UnityEngine.Rect' could be found (are you missing a using directive or an assembly reference?)

コード:

using UnityEngine;
using System.Collections;

public class GameGUI : MonoBehaviour {


    void OnResume() {
        enabled = true;
    }

    void OnPause() {
        enabled = false;
    }


    void OnGUI() {
        int fps = (int) (1f/Time.deltaTime*Time.timeScale);
        GUILayout.Box( "FPS "+fps );

        Vector2 size = GUI.skin.label.CalcSize( new GUIContent("+") );
        Rect rect = new Rect(0, 0, size.x, size.y);
        rect.center = new Vector2(Screen.width, Screen.height)/2f;
        GUI.Label( rect, "+" );
    }


}

お時間をいただきありがとうございます。

4

1 に答える 1