コード例 #1
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Debug.Log("instance already exists , destroying object");
         Destroy(this);
     }
 }
コード例 #2
0
    // Start is called before the first frame update
    void Awake()
    {
        //get components
        wave                 = FindObjectOfType <WaveCreate>();
        Rigidbody            = GetComponent <Rigidbody>();
        Rigidbody.useGravity = false;

        //compute center
        WaterLinePoints = new Vector3[FloatPoints.Length];
        for (int i = 0; i < FloatPoints.Length; i++)
        {
            WaterLinePoints[i] = FloatPoints[i].position;
        }
        centerOffset = GetCenter(WaterLinePoints) - transform.position;  //오브젝트의 중심 점과 라인 포인트 중심점의 거리계산
    }