Skip to content

Fixes for pooling Unity UI, and automatic pool creation. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Simplified SetParent setup
  • Loading branch information
Brett Johnson authored and Brett Johnson committed Jun 18, 2016
commit be6ba79fdaec61f758cf9d7a7da7afa0ef108b13
6 changes: 2 additions & 4 deletions Assets/ObjectPool/Scripts/ObjectPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ public static GameObject Spawn(GameObject prefab, Transform parent, Vector3 posi
trans = obj.transform;
if (parent != null)
{
bool worldPositionStays = (parent.GetComponent<RectTransform>() == null);
trans.SetParent(parent, worldPositionStays);
trans.SetParent(parent, false); // worldPositionStays=false to keep UI objects spawning consistently
}
trans.localPosition = position;
trans.localRotation = rotation;
Expand All @@ -134,8 +133,7 @@ public static GameObject Spawn(GameObject prefab, Transform parent, Vector3 posi
trans = obj.transform;
if (parent != null)
{
bool worldPositionStays = (parent.GetComponent<RectTransform>() == null);
trans.SetParent(parent, worldPositionStays);
trans.SetParent(parent, false); // worldPositionStays=false to keep UI objects spawning consistently
}
trans.localPosition = position;
trans.localRotation = rotation;
Expand Down
6 changes: 1 addition & 5 deletions ObjectPool.userprefs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<Properties StartupItem="Assembly-CSharp.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Unity.Instance.Unity Editor" />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/ObjectPool/Scripts/ObjectPool.cs">
<Files>
<File FileName="Assets/ObjectPool/Scripts/ObjectPool.cs" Line="516" Column="2" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.Workbench />
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
Expand Down