|
@@ -44,13 +44,13 @@ |
44 |
44 |
|
|
45 |
45 |
|
void FixedUpdate(){ |
46 |
46 |
|
|
47 |
|
- |
Vector2 screenPos = cam.WorldToScreenPoint( rigidbody.position); |
|
47 |
+ |
Vector2 screenPos = cam.WorldToScreenPoint( GetComponent<Rigidbody>().position); |
48 |
48 |
|
|
49 |
49 |
|
if ( screenPos.x> Screen.width ||screenPos.y<0 ||screenPos.y> Screen.height) |
50 |
50 |
|
Destroy( gameObject); |
51 |
51 |
|
|
52 |
52 |
|
if (screenPos.x<transform.localScale.x/2){ |
53 |
|
- |
rigidbody.AddForce( rigidbody.velocity *-100); |
|
53 |
+ |
GetComponent<Rigidbody>().AddForce( GetComponent<Rigidbody>().velocity *-100); |
54 |
54 |
|
} |
55 |
55 |
|
} |
56 |
56 |
|
|
|
@@ -63,7 +63,7 @@ |
63 |
63 |
|
void On_TouchStart(Gesture gesture){ |
64 |
64 |
|
|
65 |
65 |
|
if (gesture.pickObject == gameObject){ |
66 |
|
- |
rigidbody.constraints = RigidbodyConstraints.FreezeAll; |
|
66 |
+ |
GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; |
67 |
67 |
|
} |
68 |
68 |
|
} |
69 |
69 |
|
|
|
@@ -73,7 +73,7 @@ |
73 |
73 |
|
if (gesture.pickObject == gameObject){ |
74 |
74 |
|
GameObject child=null; |
75 |
75 |
|
|
76 |
|
- |
rigidbody.constraints = RigidbodyConstraints.None; |
|
76 |
+ |
GetComponent<Rigidbody>().constraints = RigidbodyConstraints.None; |
77 |
77 |
|
|
78 |
78 |
|
foreach (Transform childreen in transform ){ |
79 |
79 |
|
if (childreen.name=="ring") |
|
@@ -84,8 +84,8 @@ |
84 |
84 |
|
|
85 |
85 |
|
GameObject ring = Instantiate(Resources.Load("Ring01"), transform.position , Quaternion.identity) as GameObject; |
86 |
86 |
|
ring.transform.localScale = transform.localScale * 1.5f; |
87 |
|
- |
ring.AddComponent("SlowRotate"); |
88 |
|
- |
ring.renderer.material.SetColor ("_TintColor", renderer.material.GetColor("_TintColor")); |
|
87 |
+ |
ring.AddComponent<SlowRotate>(); |
|
88 |
+ |
ring.GetComponent<Renderer>().material.SetColor ("_TintColor", GetComponent<Renderer>().material.GetColor("_TintColor")); |
89 |
89 |
|
|
90 |
90 |
|
ring.transform.parent = transform; |
91 |
91 |
|
ring.name="ring"; |
|
@@ -105,7 +105,7 @@ |
105 |
105 |
|
if (gesture.pickObject == gameObject){ |
106 |
106 |
|
GameObject child=null; |
107 |
107 |
|
|
108 |
|
- |
rigidbody.constraints = RigidbodyConstraints.None; |
|
108 |
+ |
GetComponent<Rigidbody>().constraints = RigidbodyConstraints.None; |
109 |
109 |
|
|
110 |
110 |
|
foreach ( Transform childreen in transform){ |
111 |
111 |
|
if (childreen.name=="ring") |
|
@@ -123,9 +123,9 @@ |
123 |
123 |
|
|
124 |
124 |
|
if (gesture.pickObject == gameObject){ |
125 |
125 |
|
Vector3 position = gesture.GetTouchToWordlPoint(8); |
126 |
|
- |
deltaPosition = position - rigidbody.position; |
|
126 |
+ |
deltaPosition = position - GetComponent<Rigidbody>().position; |
127 |
127 |
|
|
128 |
|
- |
rigidbody.constraints = RigidbodyConstraints.None; |
|
128 |
+ |
GetComponent<Rigidbody>().constraints = RigidbodyConstraints.None; |
129 |
129 |
|
} |
130 |
130 |
|
} |
131 |
131 |
|
|
|
@@ -135,7 +135,7 @@ |
135 |
135 |
|
if (gesture.pickObject == gameObject){ |
136 |
136 |
|
Vector3 position = gesture.GetTouchToWordlPoint(8); |
137 |
137 |
|
|
138 |
|
- |
rigidbody.position = position - deltaPosition; |
|
138 |
+ |
GetComponent<Rigidbody>().position = position - deltaPosition; |
139 |
139 |
|
} |
140 |
140 |
|
|
141 |
141 |
|
} |
|
@@ -144,7 +144,7 @@ |
144 |
144 |
|
void On_DragEnd( Gesture gesture){ |
145 |
145 |
|
|
146 |
146 |
|
if (gesture.pickObject == gameObject){ |
147 |
|
- |
rigidbody.AddForce( gesture.deltaPosition * gesture.swipeLength/10 ); |
|
147 |
+ |
GetComponent<Rigidbody>().AddForce( gesture.deltaPosition * gesture.swipeLength/10 ); |
148 |
148 |
|
} |
149 |
149 |
|
|
150 |
150 |
|
} |