Last active
May 9, 2018 01:14
-
-
Save st0326s/0b3f0e48b6de7cb06585a7d986ff74c2 to your computer and use it in GitHub Desktop.
拡張メソッド作り方 メモ ref: https://qiita.com/satotin/items/b643cc6765009b75f20e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class ExtensionTest : MonoBehaviour { | |
public void OnExtensionTest() | |
{ | |
var test = new Test() | |
{ | |
a = 1, | |
b = "abc" | |
}; | |
test.AddValue(); | |
Debug.Log("a = " + test.a.ToString()); | |
Debug.Log("b = " + test.b); | |
Debug.Log("c = " + test.c); | |
Debug.Log("d = " + test.d); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test { | |
public int a; | |
public string b; | |
public bool c = false; | |
public float d = 0.0f; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class TestExtension { | |
public static void AddValue(this Test test) | |
{ | |
test.c = true; | |
test.d = 123.4f; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment