반응형

Unity-iPhone

  • Build Settings
    • Build Options
      • Always Embed Swift Standard libraries = yes

UnityFramework

  • Build Settings
    • Build Options
      • Always Embed Swift Standard libraries = no

공통

  • BuildSetting
    • Build Options
      • Enable Bitcode = no

로 설정해준다.

 

 

 

반응형

'개발관련 > Unity' 카테고리의 다른 글

앱 이름 다국어 설정  (0) 2023.11.06
해상도 고정  (0) 2023.09.02
TextMeshPro 폰트 생성  (0) 2023.07.31
클리커 게임 단위 구하기  (0) 2023.03.15
Addressables 동기 사용법 및 주의점  (0) 2022.09.12
반응형

다국어 설정은 Localization 해당 패키지를 이용한다.

Localization 1.3.2 버전은 버그가 있기 때문에 1.4.3 버전으로 업그레이드 해야한다.

 

 

Localization Tables를 클릭한다.

Localization이란 폴더를 만들고 해당 폴더에 Localization Settings.asset을 저장한다.

그러면 아래의 화면이 뜨고 Locale Generator를 클릭합니다.

저는 한국어와 영어를 선택했습니다. 필요시에 추가적으로 언어를 선택합니다. Generate Locales 클릭합니다.

 

Create 버튼을 클릭합니다. 적당한 폴더를 설정해줍니다.

 

Add New Entry를 클릭하고 key에는 app_name을 입력

영어와 한글에 맞게 앱 이름을 설정합니다.

 

유니티 인스펙터에서 Localization 경로에 세팅한 Localization Settings 을 클릭합니다. 그리고 아래의 그림에 맞춰 + 버튼을 클릭합니다. 그리고 Android Appinfo를 클릭합니다.

 

Display Name을 클릭하면 등록한 app_name이 보입니다.

 

반응형

'개발관련 > Unity' 카테고리의 다른 글

xcode upload contain disallowed file 'Frameworks'  (0) 2023.11.09
해상도 고정  (0) 2023.09.02
TextMeshPro 폰트 생성  (0) 2023.07.31
클리커 게임 단위 구하기  (0) 2023.03.15
Addressables 동기 사용법 및 주의점  (0) 2022.09.12
반응형

유니티 API를 Screen.SetResolution 호출하는 경우
이 해상도를 맞추기 위해 인게임의 화면 비율을 강제로 늘리거나 줄이거나 해버린다.

세로일때는 정상이나 가로로 돌렸을 경우 타일들이 늘어난 것을 볼 수 있다.

 

그래서 해상도의 비율을 고정하기 위해서 최대 공약수로 타겟 해상도의 비율을 구한다.

 

이후에 그 비율만큼 디바이스의 높이와 넓이를 설정한다.

public void SetResolutionBasedOnRatio()
{
    DeviceWidth = Screen.width;
    DeviceHeight = Screen.height;

    int gcdValue = GCD(TargetWidth, TargetHeight);

    float targetWidthRatio = (float)TargetWidth / gcdValue;
    float targetHeightRatio = (float)TargetHeight / gcdValue;

    int proposedHeight = (int)(DeviceWidth * targetHeightRatio / targetWidthRatio);
    int proposedWidth = (int)(DeviceHeight * targetWidthRatio / targetHeightRatio);

    if (proposedHeight <= DeviceHeight)
    {
        Screen.SetResolution(DeviceWidth, proposedHeight, true);
    }
    else
    {
        Screen.SetResolution(proposedWidth, DeviceHeight, true);
    }
}

private int GCD(int a, int b)
{
    return b == 0 ? a : GCD(b, a % b);
}

 

위의 방법 말고 레터박스를 깔기 위해선 다른 방법을 사용해야한다.

public IEnumerator AdjustCameraViewportToAspectRatio(Camera camera)
{
    yield return null;
    var rect = camera.rect;
    var scaleheight = (float)DeviceWidth / DeviceHeight / ((float)TargetWidth / TargetHeight);
    var scalewidth = 1F / scaleheight;
    if (scaleheight < 1F)
    {
        rect.height = scaleheight;
        rect.y = (1f - scaleheight) / 2F;
    }
    else
    {
        rect.width = scalewidth;
        rect.x = (1f - scalewidth) / 2F;
    }
    camera.rect = rect;
}

 

반응형
반응형

Font Asset Creator 클릭

Character Set에 Custom Range 선택

32-126,44032-55203,12593-12643,8200-9900

 

영어 32-126

한글 44032-55203

한글 자음 모음 12593-12643

특수문자 8200-9000

 

 

Generate Font Atlas 클릭

 

기다렸다가 Save

 

TextMesh Pro Resource에서 TMP Settings 선택

위에서 생성한 폰트 Asset을 Default로 설정

 

 

반응형

'개발관련 > Unity' 카테고리의 다른 글

앱 이름 다국어 설정  (0) 2023.11.06
해상도 고정  (0) 2023.09.02
클리커 게임 단위 구하기  (0) 2023.03.15
Addressables 동기 사용법 및 주의점  (0) 2022.09.12
곡사체 관련 공식  (0) 2021.03.20
반응형

1000 = 1A

1000000 = 1B

namespace GameUtils
{
    public class BigNumberHelper
    {
        internal static readonly char[] MagnitudeUnits = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };

        private static string _numberFormat = "{0:F3}";
        public static void Init(string format)
        {
            _numberFormat = format;
        }
        public static string BigNumberToString(BigNumber bigNumber)
        {
            if(bigNumber.Magnitude >=0)
            {
                return $"{string.Format(_numberFormat, bigNumber.Value)}{bigNumber.MagnitudeLabel}";
            }
            else
            {
                return bigNumber.Value.ToString();
            }
        }
    }
}
using System;
using System.Text;

namespace GameUtils
{
    public struct BigNumber
    {
        public double Value { get; private set; }
        public int Magnitude { get; private set; }
        public string MagnitudeLabel { get; private set; }

        public string DisplayValue
        {
            get
            {
                if (string.IsNullOrEmpty(_displayValue))
                {
                    BigNumberHelper.BigNumberToString(this);
                }
                return _displayValue;
            }
        }

        private readonly string _displayValue;
        public BigNumber(double value) : this(value, -1)
        {
        }
        public BigNumber(double value, int digit = -1)
        {
            while (value >= 1000)
            {
                value /= 1000;
                digit++;
            }
            Magnitude = digit;
            Value = value;

            var sb = new StringBuilder();
            while (digit >= 0)
            {
                sb.Insert(0, BigNumberHelper.MagnitudeUnits[digit % BigNumberHelper.MagnitudeUnits.Length]);
                digit = digit / BigNumberHelper.MagnitudeUnits.Length - 1;
            }
            MagnitudeLabel = sb.ToString();
            _displayValue = string.Empty;
        }
        public static BigNumber operator +(BigNumber number1, BigNumber number2)
        {
            double convertedValue1 = number1.Value;
            double convertedValue2 = number2.Value;
            int finalMagnitude = number1.Magnitude;
            if (number1.Magnitude > number2.Magnitude)
            {
                for (int i = 0; i < (number1.Magnitude - number2.Magnitude); i++)
                {
                    convertedValue2 /= 1000;
                }
            }
            else if (number1.Magnitude < number2.Magnitude)
            {
                for (int i = 0; i < (number2.Magnitude - number1.Magnitude); i++)
                {
                    convertedValue1 /= 1000;
                }
                finalMagnitude = number2.Magnitude;
            }
            var value = convertedValue1 + convertedValue2;

            return new BigNumber(value, finalMagnitude);

        }
        public static BigNumber operator -(BigNumber number1, BigNumber number2)
        {
            double convertedValue1 = number1.Value;
            double convertedValue2 = number2.Value;
            int finalMagnitude = number1.Magnitude;

            if (number1.Magnitude > number2.Magnitude)
            {
                for (int i = 0; i < (number1.Magnitude - number2.Magnitude); i++)
                {
                    convertedValue2 /= 1000;
                }
            }
            else if (number1.Magnitude < number2.Magnitude)
            {
                for (int i = 0; i < (number2.Magnitude - number1.Magnitude); i++)
                {
                    convertedValue1 /= 1000;
                }
                finalMagnitude = number2.Magnitude;
            }

            var value = convertedValue1 - convertedValue2;
            if (Math.Abs(value) < 1)
            {
                value *= 1000;
                finalMagnitude--;
            }
            return new BigNumber(value, finalMagnitude);
        }
    }
}
반응형

'개발관련 > Unity' 카테고리의 다른 글

해상도 고정  (0) 2023.09.02
TextMeshPro 폰트 생성  (0) 2023.07.31
Addressables 동기 사용법 및 주의점  (0) 2022.09.12
곡사체 관련 공식  (0) 2021.03.20
could not create asset from file could not be read  (0) 2021.01.06
반응형

생성과 릴리즈는 짝을 맞춘다.

Addressables.LoadAssetAsync = Addressables.Release
Addressables.InstantiateAsync = Addressables.ReleaseInstance

 

대부분 비동기로 이뤄짐으로 씬에서 여러가지 요청으로 비동기 관리가 힘들다면 

 

var op = Addressables.LoadAssetAsync<GameObject>(path);

var prefab = op.WaitForCompletion();

 

이런식으로 동기형으로 사용이 가능하다.

 

주의점

 

메모리 해제시 씬 객체가 참조를 물고 있다면 Addressables Release를 하더라도  메모리에 계속해서 상주하게 된다.

이때 Addressables Resource 릴리즈 관리는 씬으로 넘어가게 되고 씬에서 객체가 파괴가 되면 레퍼런스 카운트 체크를 통해 릴리즈가 된다.

 

AddressableAssetSettings 클릭해서 프로파일링 설정

 

 

반응형

'개발관련 > Unity' 카테고리의 다른 글

해상도 고정  (0) 2023.09.02
TextMeshPro 폰트 생성  (0) 2023.07.31
클리커 게임 단위 구하기  (0) 2023.03.15
곡사체 관련 공식  (0) 2021.03.20
could not create asset from file could not be read  (0) 2021.01.06
반응형
        protected IEnumerator ProcessProjectileParabolicAttack(EffectHandler skillEffect, Transform target, float delay = 0f)
        {
            if(delay > 0)
            {
                yield return new WaitForSeconds(delay);
            }
            
            skillEffect.InvokeEffect();

            var speed = UnitHandler.GetAnimationSpeed();

            var maximumHeightArrivalTime = fireTime / speed / 2F / 1000F; 
            var startPosition = skillEffect.transform.position;
            var endPosition = target.position;
            var maxHeight = Math.Max(startPosition.y, target.position.y) + Height;

            //높이가 음수 or 0이 되면 안된다.
            var mh = maxHeight - startPosition.y;

            var g = 2 * mh / (maximumHeightArrivalTime * maximumHeightArrivalTime);

            var vY = Mathf.Sqrt(2 * g * mh);

            //도착 지점 도달 시간
            //float a = g;
            //float b = -2 * vY;
            //float c = 2 * (endPosition.y - startPosition.y);
            //var dat = (-b + Mathf.Sqrt(b * b - 4 * a * c)) / (2 * a);
            
            var dat = fireTime / speed / 1000F ;

            //X축 속도
            var vX = -(startPosition.x - endPosition.x) / dat;

            var time = 0F;
           
            //vX = speed * vX;

            for (; ; )
            {
                time += Time.deltaTime;
                var tx = startPosition.x + vX * time;
                var ty = startPosition.y + (vY * time) - (0.5f * g * time * time);

                if(float.IsNaN(tx) == true)
                {
                    skillEffect.Clear();
                    break;
                }
                var tpos = new Vector3(tx, ty, 0);

                var angle = LookAt(skillEffect.transform.position, tpos);

                skillEffect.transform.position = tpos;
                skillEffect.transform.eulerAngles = new Vector3(0, 0, angle);

                var distance = skillEffect.transform.position - target.position;
                if (distance.sqrMagnitude <= 0.2F)
                {
                    skillEffect.Clear();
                    break;
                }
                //안전빵
                if(skillEffect.transform.position.y <= 0)
                {
                    skillEffect.Clear();
                    break;
                }
                yield return null;
            }
            yield break;
        }
        protected float LookAt(Vector3 obj, Vector3 lookObject)
        {
            var dir = lookObject - obj;
            if(dir.x < 0)
            {
                return Mathf.Atan2(obj.y - lookObject.y, obj.x - lookObject.x) * Mathf.Rad2Deg;
            }
            else
            {
                return Mathf.Atan2(lookObject.y - obj.y, lookObject.x - obj.x) * Mathf.Rad2Deg;
            }
        }
반응형

'개발관련 > Unity' 카테고리의 다른 글

해상도 고정  (0) 2023.09.02
TextMeshPro 폰트 생성  (0) 2023.07.31
클리커 게임 단위 구하기  (0) 2023.03.15
Addressables 동기 사용법 및 주의점  (0) 2022.09.12
could not create asset from file could not be read  (0) 2021.01.06
반응형

유니티 버전 업을 한 후 이미지 파일이 깨지는 경우가 발생한다. 

 

간단한 해결 방법은 디자이너를 괴롭히는 방법으로 이미지를 포멧 방식을 바꿔서 새롭게 Export를 요청한다.

 

또는 C#으로 Png 이미지의 메타 정보를 수정하는 방법이 있다.

 

정상적인 이미지의 메타 정보와 비정상적으로 보이는 메타 정보를 비교하여 빠진 메타 정보를 삽입해주면 된다.

 

응용하면 재귀로 모든 이미지 파일 검색하여 빠진 메타 정보를 삽입해 줄 수 있다.

 

Code>>

 

using System;
using System.Drawing;
using System.IO;
using System.Windows;

namespace ReadPngSample
{
    class Program
    {
        static void Main(string[] args)
        {

            var bmp = new Bitmap($@"NormalSample.png");
            
            var propItems = bmp.PropertyItems;
            foreach (System.Drawing.Imaging.PropertyItem items in propItems)
            {
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                Console.WriteLine(items.Type + " : " + items.Id + " = " + items.Value.ToString() + "(len : " + items.Len + ")");
            }
            Console.WriteLine();
 
            //빠진 메타 정보임
            var prop = bmp.GetPropertyItem(305);
            bmp = new Bitmap($@"ErrorImamge.png");
            //메타 정보 삽입
            bmp.SetPropertyItem(prop);
            propItems = bmp.PropertyItems;
            foreach (System.Drawing.Imaging.PropertyItem items in propItems)
            {
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                Console.WriteLine(items.Type + " : " + items.Id + " = " + items.Value.ToString() + "(len : " + items.Len + ")");
            }
            Console.WriteLine();
            bmp.Save($@"NewErrorImamge.png");
            Console.ReadKey();
        }
    }
}

 

 

반응형

'개발관련 > Unity' 카테고리의 다른 글

해상도 고정  (0) 2023.09.02
TextMeshPro 폰트 생성  (0) 2023.07.31
클리커 게임 단위 구하기  (0) 2023.03.15
Addressables 동기 사용법 및 주의점  (0) 2022.09.12
곡사체 관련 공식  (0) 2021.03.20

+ Recent posts