facebook twitter hatena line email

「Unity/Csharp/クラス」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(クラスやプロパティ)
 
(同じ利用者による、間の39版が非表示)
行1: 行1:
==クラスやプロパティ==
+
[[Unity/Csharp/クラス/基本]]
public class CanvasScript : MonoBehaviour {
+
private int cnt = 1;
+
void Start () {
+
Debug.Log("helloworld" + cnt);
+
Add(10, 15)
+
}
+
void Update () {
+
}
+
public int Add(int x, int y) {
+
return x + y;
+
}
+
}
+
  
メンバはpublicとprivateがあり省略するとprivateになる。
+
[[Unity/Csharp/クラス/アクセス修飾子]]
  
==継承と基底クラスのメソッドへのアクセス==
+
[[Unity/Csharp/クラス/クラス分割]]
base.を使う
+
  
abstract class Animal
+
[[Unity/Csharp/クラス/継承元から継承先実行]]
{
+
 
    public virtual void Call()
+
[[Unity/Csharp/クラス/インターフェイス]]
    {
+
    }
+
}
+
class Cat : Animal
+
{
+
    public override void Call()
+
    {
+
        base.Call();
+
    }
+
}
+

2022年8月8日 (月) 15:08時点における最新版

Unity/Csharp/クラス/基本

Unity/Csharp/クラス/アクセス修飾子

Unity/Csharp/クラス/クラス分割

Unity/Csharp/クラス/継承元から継承先実行

Unity/Csharp/クラス/インターフェイス