Skip to content

Instantly share code, notes, and snippets.

@st0326s
Last active May 9, 2018 01:14
Show Gist options
  • Save st0326s/0b3f0e48b6de7cb06585a7d986ff74c2 to your computer and use it in GitHub Desktop.
Save st0326s/0b3f0e48b6de7cb06585a7d986ff74c2 to your computer and use it in GitHub Desktop.
拡張メソッド作り方 メモ ref: https://qiita.com/satotin/items/b643cc6765009b75f20e
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);
}
}
public class Test {
public int a;
public string b;
public bool c = false;
public float d = 0.0f;
}
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