엑셀의 모든 시트를 각각의 csv로 내보내기

유니티 & C#|2020. 7. 12. 19:37
Sub exportSheetsToCSV()
Dim ws As Worksheet
Dim path As String

path = ActiveWorkbook.path & "\" & Left(ActiveWorkbook.Name, InStr(ActiveWorkbook.Name, ".") - 1)
For Each ws In Worksheets
    ws.Copy
    ActiveWorkbook.SaveAs Filename:=path & " " & ws.Name & ".csv", FileFormat:=xlCSVUTF8, CreateBackup:=False
    ActiveWorkbook.Close False
Next
End Sub

엑셀로 된 데이터베이스를 CSV로 변환하여 유니티에서 불러오기에 좋다.

댓글()

유니티 프로젝트 창 아이콘 Custom GUI

유니티 & C#|2020. 6. 30. 00:10
public class GizmoIconUtility
{
	[DidReloadScripts]
	static GizmoIconUtility()
	{
		EditorApplication.projectWindowItemOnGUI = ItemOnGUI;
	}

	static void ItemOnGUI(string guid, Rect rect)
	{
		string assetPath = AssetDatabase.GUIDToAssetPath(guid);
		ItemDefinition item = AssetDatabase.LoadAssetAtPath<ItemDefinition>(assetPath);

		if (item == null ||
			item.Icon == null)
		{
			return;
		}

		rect.height = rect.width;

		EditorGUI.DrawRect(rect, BackgroundColor);
		GUI.DrawTexture(rect, LoadTextureByRarity(item.Rarity));

		var iconRect = new Rect(rect);
		var center = iconRect.center;

		iconRect.width = rect.width * 0.75f;
		iconRect.height = rect.height * 0.75f;
		iconRect.center = center;

		GUI.DrawTexture(iconRect, item.Icon.texture, ScaleMode.ScaleToFit);

		var levelRect = new Rect(rect);
		levelRect.height = 18;

		string type = item.ItemType == ItemType.Weapon ? item.WeaponType.ToString() : item.ItemType.ToString();

		EditorGUI.LabelField(levelRect, $"Lv.{item.ItemLevel} / {type}", EditorStyles.miniBoldLabel);
	}

	static Texture LoadTextureByRarity(ItemRarity rarity)
	{
		switch (rarity)
		{
			case ItemRarity.Common:
				return AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/_Project/Gizmos/Common.png");
			case ItemRarity.Uncommon:
				return AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/_Project/Gizmos/Uncommon.png");
			case ItemRarity.Rare:
				return AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/_Project/Gizmos/Rare.png");
			case ItemRarity.Epic:
				return AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/_Project/Gizmos/Epic.png");
			case ItemRarity.Legendary:
				return AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/_Project/Gizmos/Legendary.png");
			case ItemRarity.Artifact:
				return AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/_Project/Gizmos/Artifact.png");
		}

		return Texture2D.blackTexture;
	}

	private static Color BackgroundColor => EditorGUIUtility.isProSkin
		? new Color32(56, 56, 56, 255)
		: new Color32(194, 194, 194, 255);

EditorApplication.projectWindowItemOnGUI를 통해 프로젝트 창에서 임의로 아이콘을 그려 넣을 수 있다

댓글()

2D 발사체 포물선 이동

유니티 & C#|2020. 6. 20. 20:18
Vector2 position = transform.position;

Vector2 d = destination - position;
float angle = Vector2.SignedAngle(Vector2.right, d.normalized) + 11.25f;

Vector2 p1 = new Vector2(position.x, 0f);
Vector2 d1 = new Vector2(destination.x, 0f);

float r = Vector2.Distance(p1, d1);
float t = Mathf.Tan(angle * Mathf.Deg2Rad);
float h = destination.y - position.y;

float vx = Mathf.Sqrt(Physics2D.gravity.y * r * r / (2.0f * (h - r * t)));
float vy = t * vx;

Velocity = new Vector2(vx, vy);

댓글()

UIElements UXML 정리

유니티 & C#|2020. 2. 24. 11:49
보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

Unity GameObject Pooling

유니티 & C#|2019. 12. 25. 01:07

https://github.com/wakeup5/Unity-GameObject-Pooling

간단히 게임오브젝트 풀을 생성하고 불러올 수 있는 라이브러리이다.

사용방법

// Pool of GameObject
public GameObject original1;

IPool<GameObject> pool = Pool.OfGameObject(original1);
pool.ActivateOne(Vector3.zero, Quaternion.identity);

// Pool of MonoBehaviour
public Monster original2; // public class Monster : MonoBehaviour

IPool<Monster> pool = Pool.OfBehaviour(original2);
pool.ActivateOne();

// Pool of Poolable
public Bullet original3; // public class Bullet : Poolable (: MonoBahaviour)

var instance = Pool.OfPoolable(original3).ActivateOne(); // 바로 호출하여 사용 가능
instance.Pool; // Pool에 접근 가능.
instance.Original; // Original Prefab에 접근 가능.

// for RectTransform
public Text floatingDamage;
public RectTransform uiParent;

var pool = Pool.OfBehaviour(floatingDamage, uiParant); // create objects on RectTransform;
pool.ActivateOne();

댓글()

Save over 90% on our largest Mega Bundles!

에셋 스토어에서 최대 90%까지 할인되는 메가 번들을 판매합니다.

https://assetstore.unity.com/browse/mega-bundles

Synty Studios Mega Bundle

이미지를 클릭하여 이동

https://assetstore.unity.com/mega-bundles/synty-studios

Whether you're starting from scratch, working on a game jam or building onto your game, grab 17 of their most popular asset packs at over 90% off, and take your game to new worlds.

처음부터 시작하거나 게임 잼 혹은 게임을 구축 할 때 사용되는 가장 인기있는 자산 팩 17개를 90% 이상 할인 된 가격에 구입하여 새로운 세계로 이끌어보십시오.

World Building Mega Bundle

이미지를 클릭하여 이동

https://assetstore.unity.com/mega-bundles/world-building

From ocean waves to volumetric clouds to trees so realistic you can practically smell them, these assets are the secret sauce in many top game devs' toolkits.

파도에서 구름, 나무에 이르기까지 현실적인 냄새를 맡을 수 있습니다. 이 자산은 최고의 많은 게임의 비밀 개발자 도구 키트입니다.

Snaps Mega Bundle

이미지를 클릭하여 이동

Quickly and easily create prototypes using snap-in 3D frameworks, then swap in complementary AAA-quality art to take your game to the finish line.

스냅인 3D 프레임 워크를 사용하여 프로토 타입을 빠르고 쉽게 만든 다음 보완적인 AAA 품질 아트로 바꾸어 게임을 결승선으로 가져갑니다.

'유니티 & C# > 유니티 에셋 할인' 카테고리의 다른 글

Power Tools Mega Bundle  (0) 2020.07.15

댓글()