Skip to content

Commit 6b47d81

Browse files
committed
파일 업로드
1 parent 3458132 commit 6b47d81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+121698
-0
lines changed
413 Bytes
Binary file not shown.
Binary file not shown.

.vs/ObjectPool/FileContentIndex/read.lock

Whitespace-only changes.

.vs/ObjectPool/v17/.futdcache.v1

232 Bytes
Binary file not shown.

.vs/ObjectPool/v17/.suo

29 KB
Binary file not shown.
126 KB
Binary file not shown.
57 KB
Binary file not shown.

ObjectPool.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.2.32602.215
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObjectPool", "ObjectPool\ObjectPool.csproj", "{4801F2CB-5A69-4A64-AE75-AA056051925F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{4801F2CB-5A69-4A64-AE75-AA056051925F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4801F2CB-5A69-4A64-AE75-AA056051925F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4801F2CB-5A69-4A64-AE75-AA056051925F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4801F2CB-5A69-4A64-AE75-AA056051925F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {486945CE-41E0-4672-8A36-9D94ABEEC3BB}
24+
EndGlobalSection
25+
EndGlobal

ObjectPool/Class1.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System.Collections.Generic;
2+
using UnityEngine;
3+
namespace ObjectPool
4+
{ public class ObjectPool<T> where T : Component
5+
{
6+
private List<T> _pool = new List<T>();
7+
private int _count = 0;
8+
private T _prefab;
9+
10+
public ObjectPool(T prefab)
11+
{
12+
_prefab = prefab;
13+
Create();
14+
}
15+
16+
public void Create()
17+
{
18+
T unit = UnityEngine.Object.Instantiate(_prefab).GetComponent<T>();
19+
unit.gameObject.SetActive(false);
20+
_pool.Add(unit);
21+
}
22+
23+
public T Pop()
24+
{
25+
if (_count > _pool.Count - 1)
26+
{
27+
if (_pool[0].gameObject.activeSelf)
28+
{
29+
Create();
30+
}
31+
else
32+
{
33+
_count = 0;
34+
}
35+
}
36+
_pool[_count].gameObject.SetActive(true);
37+
return _pool[_count++];
38+
}
39+
}
40+
41+
}

ObjectPool/ObjectPool.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<Reference Include="UnityEngine">
11+
<HintPath>..\..\..\Unity\2021.3.5f1\Editor\Data\Managed\UnityEngine.dll</HintPath>
12+
</Reference>
13+
</ItemGroup>
14+
15+
</Project>

0 commit comments

Comments
 (0)