Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unity C# for beginner - unity part -

mattak
June 28, 2016

Unity C# for beginner - unity part -

mattak

June 28, 2016
Tweet

More Decks by mattak

Other Decks in Programming

Transcript

  1. C# Unity  (BNF0CKFDU  .POP#FIBWJPVS  3FTPVSDFT  *OTUBOUJBUF

     %FTUSPZ  $PNQPOFOU  *OQVU  %FCVH  1SPpMF
  2. ͢΂ͯͷ(BNF0CKFDU͸ԼهΛ࣋ͭ this.gameObject.transform; // زԿม׵Λߦ͏ object
 this.gameObject.name; // Inspector্Ͱදࣔ͞ΕΔ໊લ
 this.gameObject.tag; //

    Inspector্Ͱઃఆ͞ΕΔλά໊
 this.gameObject.activeSelf; // ͜ͷGameObject͕༗ޮԽͲ͏͔ʁ
 this.gameObject.isStatic; // GameObject͕੩త෺ମԽͲ͏͔?
 this.gameObject.layer; // GameObject͕ॴଐ͢ΔϨΠϠʔ໊ ࠲ඪΛॴ༗͠ͳ͍(BNF0CKFDU͸ଘࡏ͠ͳ͍
  3. ֤छϓϩύςΟ (BNF0CKFDU΁ͷγϣʔτΧοτ΋࣋ͭ this.enabled; // εΫϦϓτ͕༗ޮԽͲ͏͔
 this.isActiveAndEnabled; // εΫϦϓτ͕༗ޮͰGameObject͕༗ޮ͔ʁ 
 this.gameObject;

    // GameObject΁ͷࢀর
 this.tag; // λά
 this.transform; // زԿมܗΛߦ͏ object
 this.hideFlags; // 
 this.name; // Inspector্Ͱදࣔ͞ΕΔ໊લ
  4. $PSPVUJOFͷ։࢝΋Ͱ͖Δ public class SampleBehaviour : MonoBehaviour
 {
 void Start()
 {


    this.StartCoroutine(Hoge());
 }
 
 IEnumerator Hoge()
 {
 yield return null;
 }
 }
  5. 'JOEͰ୳͢ GameObject obj1 = GameObject.Find("Sample");
 GameObject obj2 = GameObject.FindGameObjectWithTag("Player");
 GameObject

    obj3 = GameObject.FindObjectOfType<GUITexture>(); جຊతʹ͸UBHΛ͚ͭͯ୳͢ͷ͕ૣͯ͘ྑ͍ ͦ΋ͦ΋୳͞ͳ͍ͰࡁΉઃܭ͕Α͍
  6. public class SampleBehaviour : MonoBehaviour
 {
 void Update()
 {
 if

    (Input.GetKey(KeyCode.Space))
 {
 // εϖʔεΛԡͯ͠Δؒtrue
 }
 
 if (Input.GetKeyDown(KeyCode.Space))
 {
 // εϖʔεΛԡԼͨ͠ॠؒͷΈtrue
 }
 
 if (Input.GetKeyUp(KeyCode.Space))
 {
 // εϖʔεΛԡԼͯ͠཭ͨ͠ॠؒͷΈtrue
 }
 }
 } (FU,FZϘλϯೖྗΛऔಘ
  7. // λονΠϕϯτͷॲཧ
 if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)


    {
 }
 
 TouchPhase.Began; // ։࢝
 TouchPhase.Ended; // ऴྃ
 TouchPhase.Moved; // Ҡಈத
 TouchPhase.Stationary; // λονͨ͠··ఀࢭத
 TouchPhase.Canceled; // γεςϜଆͰΩϟϯηϧ͞Εͨ (FU5PVDIλονΠϕϯτͷऔಘ