コード例 #1
0
        public IPacMan CloneMe(Transform parent, Vector2 position)
        {
            GameObject newObj = Instantiate(gameObject, parent);
            PacMan     pacMan = newObj.GetComponent <PacMan>();

            pacMan.transform.localPosition = position;
            return(pacMan);
        }
コード例 #2
0
ファイル: PacMan.cs プロジェクト: NnX/EatSomethingMan
        public IPacMan CloneMe(Transform parent, Vector2 position, UnityEvent unityEvent)
        {
            GameObject    newObj      = Instantiate(gameObject, parent);
            BoxCollider2D boxCollider = newObj.AddComponent <BoxCollider2D>();

            boxCollider.isTrigger = true;
            Rigidbody2D rigid = newObj.AddComponent <Rigidbody2D>();

            rigid.bodyType = RigidbodyType2D.Kinematic;
            PacMan pacMan = newObj.GetComponent <PacMan>();

            pacMan.transform.localPosition = position;
            pacMan._unityEvent             = unityEvent;
            return(pacMan);
        }