|
2 | 2 |
|
3 | 3 | namespace Duck.HieriarchyBehaviour |
4 | 4 | { |
5 | | - public static class GameObjectExtensions |
| 5 | + public static partial class GameObjectExtensions |
6 | 6 | { |
7 | 7 | /// <summary> |
8 | 8 | /// Creates a new GameObject as a child transform. |
@@ -145,101 +145,5 @@ public static TComponent CreateChild<TComponent, TArgs>(this GameObject parent, |
145 | 145 | behaviour.Initialize(args); |
146 | 146 | return behaviour; |
147 | 147 | } |
148 | | - |
149 | | - /// <summary> |
150 | | - /// Destroys the child GameObject and creates a new child GameObject with the given TComponent component. |
151 | | - /// IHierarchyBehaviour's will be initialized. |
152 | | - /// </summary> |
153 | | - /// <param name="toDestroy">The child Component to destroy.</param> |
154 | | - /// <typeparam name="TComponent">The type of Component to be created.</typeparam> |
155 | | - /// <returns>The new TComponent</returns> |
156 | | - public static TComponent ReplaceChild<TComponent>(this GameObject parent, Component toDestroy) |
157 | | - where TComponent : Component |
158 | | - { |
159 | | - Utils.DestroyChild(parent, toDestroy); |
160 | | - return parent.CreateChild<TComponent>(); |
161 | | - } |
162 | | - |
163 | | - /// <summary> |
164 | | - /// Destroys the child GameObject and creates a new child GameObject with the given TComponent component. |
165 | | - /// TComponent will be initialized with the given arguements. |
166 | | - /// </summary> |
167 | | - /// <param name="toDestroy">The child Component to destroy.</param> |
168 | | - /// <param name="args">The TArgs object to be passed in on initialization.</param> |
169 | | - /// <typeparam name="TComponent">The type of Component to be created.</typeparam> |
170 | | - /// <typeparam name="TArgs">The type of arguements to be given on initialization.</typeparam> |
171 | | - /// <returns>The new TComponent</returns> |
172 | | - public static TComponent ReplaceChild<TComponent, TArgs>(this GameObject parent, Component toDestroy, TArgs args) |
173 | | - where TComponent : Component, IHierarchyBehaviour<TArgs> |
174 | | - { |
175 | | - Utils.DestroyChild(parent, toDestroy); |
176 | | - return parent.CreateChild<TComponent, TArgs>(args); |
177 | | - } |
178 | | - |
179 | | - /// <summary> |
180 | | - /// Destroys the child GameObject and creates a new child GameObject, by loading from resources and instantiating. |
181 | | - /// IHierarchyBehaviour's will be initialized. |
182 | | - /// </summary> |
183 | | - /// <param name="toDestroy">The child Component to destroy.</param> |
184 | | - /// <param name="path">The path to the resourced asset.</param> |
185 | | - /// <param name="worldPositionStays">Will the instantiated GameObject stay in its world position or be set to local origin.</param> |
186 | | - /// <typeparam name="TComponent">The type of Component to be created.</typeparam> |
187 | | - /// <returns>The new TComponent</returns> |
188 | | - public static TComponent ReplaceChild<TComponent>(this GameObject parent, Component toDestroy, string path, bool worldPositionStays = true) |
189 | | - where TComponent : Component |
190 | | - { |
191 | | - Utils.DestroyChild(parent, toDestroy); |
192 | | - return parent.CreateChild<TComponent>(path, worldPositionStays); |
193 | | - } |
194 | | - |
195 | | - /// <summary> |
196 | | - /// Destroys the child GameObject and creates a new child GameObject, by loading from resources and instantiating. |
197 | | - /// TComponent will be initialized with the given arguements. |
198 | | - /// </summary> |
199 | | - /// <param name="toDestroy">The child Component to destroy.</param> |
200 | | - /// <param name="path">The path to the resourced asset.</param> |
201 | | - /// <param name="args">The TArgs object to be passed in on initialization.</param> |
202 | | - /// <param name="worldPositionStays">Will the instantiated GameObject stay in its world position or be set to local origin.</param> |
203 | | - /// <typeparam name="TComponent">The type of Component to be created.</typeparam> |
204 | | - /// <typeparam name="TArgs">The type of arguements to be given on initialization.</typeparam> |
205 | | - /// <returns>The new TComponent</returns> |
206 | | - public static TComponent ReplaceChild<TComponent, TArgs>(this GameObject parent, Component toDestroy, string path, TArgs args, bool worldPositionStays = true) |
207 | | - where TComponent : Component, IHierarchyBehaviour<TArgs> |
208 | | - { |
209 | | - Utils.DestroyChild(parent, toDestroy); |
210 | | - return parent.CreateChild<TComponent, TArgs>(path, args, worldPositionStays); |
211 | | - } |
212 | | - |
213 | | - /// <summary> |
214 | | - /// Destroys the child GameObject and creates a clone of the given TComponent as a child transform. |
215 | | - /// IHierarchyBehaviour's will be initialized. |
216 | | - /// </summary> |
217 | | - /// <param name="toDestroy">The child Component to destroy.</param> |
218 | | - /// <param name="toClone">The GameObject to clone.</param> |
219 | | - /// <typeparam name="TComponent">The type of Component to be created.</typeparam> |
220 | | - /// <returns>The new TComponent</returns> |
221 | | - public static TComponent ReplaceChild<TComponent>(this GameObject parent, Component toDestroy, TComponent toClone) |
222 | | - where TComponent : Component |
223 | | - { |
224 | | - Utils.DestroyChild(parent, toDestroy); |
225 | | - return parent.CreateChild(toClone); |
226 | | - } |
227 | | - |
228 | | - /// <summary> |
229 | | - /// Destroys the child GameObject and creates a clone of the given TComponent as a child transform. |
230 | | - /// TComponent will be initialized with the given arguements. |
231 | | - /// </summary> |
232 | | - /// <param name="toDestroy">The child Component to destroy.</param> |
233 | | - /// <param name="toClone">The GameObject to clone.</param> |
234 | | - /// <param name="args">The TArgs object to be passed in on initialization.</param> |
235 | | - /// <typeparam name="TComponent">The type of Component to be created.</typeparam> |
236 | | - /// <typeparam name="TArgs">The type of arguements to be given on initialization.</typeparam> |
237 | | - /// <returns>The new TComponent</returns> |
238 | | - public static TComponent ReplaceChild<TComponent, TArgs>(this GameObject parent, Component toDestroy, TComponent toClone, TArgs args) |
239 | | - where TComponent : Component, IHierarchyBehaviour<TArgs> |
240 | | - { |
241 | | - Utils.DestroyChild(parent, toDestroy); |
242 | | - return parent.CreateChild(toClone, args); |
243 | | - } |
244 | 148 | } |
245 | 149 | } |
0 commit comments