'프로그램개발/C# and unity'에 해당되는 글 49건

  1. 2025.04.03 2d to 3d
  2. 2025.03.28 안드로이드 라이브러리 다운받기
  3. 2025.03.25 unity nats 샘플
  4. 2025.03.24 unity에서 NATS 사용하기
  5. 2025.02.22 unitask
  6. 2024.05.22 c# 서버에서 코루틴과 await을 사용시 장단점
  7. 2023.12.31 unity touch pan, scale
  8. 2023.12.13 어셋관리
  9. 2023.09.25 flaxEngine
  10. 2023.08.15 c# DateTime

https://huggingface.co/spaces/JeffreyXiang/TRELLIS

 

TRELLIS - a Hugging Face Space by JeffreyXiang

Running on Zero

huggingface.co

 

 

하루 GPU 사용 쿼터제한이 있음

Posted by 아기곰푸우
,

https://mvnrepository.com/ 

 

 

안드로이드 라이브러리 다운받기

Posted by 아기곰푸우
,

using System;
using System.Text;
using NATS.Client;
using NATS.Net;
using Systehttp://m.Threading.Tasks;
using NATS.Client.Core;
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;

public class NatSample : MonoBehaviour
{
    private NatsClient client;
    private const string NATS_URL = "ws://35.208.138.76:8282"; // NATS 서버 주소
    private Dictionary<string, IAsyncSubscription<string>> subscriptions = new Dictionary<string, IAsyncSubscription<string>>();

    async void Start()
    {
        await ConnectToNats();
    }

    async Task ConnectToNats()
    {
        try
        {
            client = new NatsClient(new NatsOpts { Url = NATS_URL });
            Debug.Log("Connected to NATS server");
        }
        catch (Exception e)
        {
            Debug.LogError($"NATS Connection Error: {e.Message}");
        }
    }

    public async Task AddSubject(string subject)
    {
        if (client == null || subscriptions.ContainsKey(subject))
            return;

        try
        {
            var subscription = client.SubscribeAsync<string>(subject);
            subscriptions[subject] = subscription;

            _ = Task.Run(async () =>
            {
                await foreach (var msg in subscription)
                {
                    Debug.Log($"Received on {subject}: {msg.Data}");
                    UpdateChatDisplay($"{subject}: {msg.Data}");
                }
            });

            Debug.Log($"Added subscription to subject: {subject}");
        }
        catch (Exception e)
        {
            Debug.LogError($"Error adding subject {subject}: {e.Message}");
        }
    }

    public async Task RemoveSubject(string subject)
    {
        if (client == null || !subscriptions.ContainsKey(subject))
            return;

        try
        {
            await subscriptions[subject].DisposeAsync();
            subscriptions.Remove(subject);
            Debug.Log($"Removed subscription from subject: {subject}");
        }
        catch (Exception e)
        {
            Debug.LogError($"Error removing subject {subject}: {e.Message}");
        }
    }

    public async Task SendMessage(string subject, string message)
    {
        if (client == null) return;

        try
        {
            await client.PublishAsync(subject, message);
            Debug.Log($"Sent to {subject}: {message}");
        }
        catch (Exception e)
        {
            Debug.LogError($"Error sending message: {e.Message}");
        }
    }

    void UpdateChatDisplay(string message)
    {
        Debug.Log("msg:" + message);
    }

    async void OnApplicationQuit()
    {
        if (client != null)
        {
            foreach (var subscription in subscriptions.Values)
            {
                await subscription.DisposeAsync();
            }
            await client.DisposeAsync();
        }
    }
}

Posted by 아기곰푸우
,
using System;
using System.Text;
using NATS.Client;
using NATS.Net;
using System.Threading.Tasks;
using NATS.Client.Core;
using UnityEngine;
using UnityEngine.UI;

public class NatSample : MonoBehaviour
{
    private NatsClient client;
    //private const string NATS_URL = "nats://localhost:4222"; // NATS 서버 주소
    private const string NATS_URL = "ws://localhost:8282"; // NATS 서버 주소

    private const string SUBJECT = "test"; // 채팅 채널
    async void Start()
    {
        await ConnectToNats();
    }

    async Task ConnectToNats()
    {
        try
        {
            client = new NatsClient(new NatsOpts { Url = NATS_URL });
            await foreach (var msg in client.SubscribeAsync<string>(SUBJECT))
            {
                Debug.Log($"Received: {msg}");
                UpdateChatDisplay(msg.Data);
            }
        }
        catch (Exception e)
        {
            Debug.LogError($"NATS Connection Error: {e.Message}");
        }
    }
    float t = 0.0f;
    private void Update()
    {
        t += Time.deltaTime;
        if (t>3)
        {
            t = 0;
            SendMessage2();
        }
    }
    public async void SendMessage2()
    {
        if (client == null ) return;
        
        await client.PublishAsync(SUBJECT, "1a2a");
        
    }
    void UpdateChatDisplay(string message)
    {
        Debug.Log("msg:"+ message);
    }

    async void OnApplicationQuit()
    {
        if (client != null)
        {
            await client.DisposeAsync();
        }
    }
}
Posted by 아기곰푸우
,

 

 

기존 소스을 변경시

Task 은 UniTask로 변경

async Task  => async UniTask 로

async void => async UniTaskVoid 로

 

Forget() 처리가 가능할 경우 로 async UniTaskVoid 로 처리

testA.Forget();

async UniTaskVoid testA()

{


}

 

async 가 필요없는 삭제할것

UniTask SomeFunction() { // 아무것도 하지 않음 return UniTask.CompletedTask; }

 

 

UniTaskVoid는 await할 수 없음

UniTaskVoid는 일반적인 UniTask와 다르게 await할 수 없습니다.
만약 비동기적으로 호출해야 한다면, UniTaskVoid 대신 UniTask를 사용하세요.

 

async UniTaskVoid Test() { await UniTask.Delay(500); Debug.Log("완료"); } // ❌ 잘못된 코드 (await 불가능) // await Test(); // 컴파일 에러 발생!

 

 

 

기존 함수  Get;Set; 으로 되었는건 await 함수로 만들것

 

 

UniTaskVoid 정리

특징설명

리턴값 없음 return;을 명시적으로 쓰지 않아도 됨
자동 실행됨 Forget() 없이도 실행됨
await 필수 await이 없으면 경고 발생
예외 전파됨 try-catch로 예외를 직접 처리해야 함
await 불가능 UniTaskVoid는 await할 수 없음 → UniTask를 사용해야 함

 

 

추천: UniTaskVoid는 주로 Unity의 이벤트 기반 코드(Update, OnTriggerEnter 등)에서 사용하고, 일반적인 비동기 함수에서는 UniTask를 사용하는 것이 더 안전합니다.

 

 

 

코루틴 -> To.Coroutine()

Forget() 사용시 이후 코드와 동시혹은 늦게 되어도 상관없는 코드일경우에 적용하고 

문제 발생하면 상위 단계로 올라가서 Forget() 처리

 

 

 

 

 

webgl 빌드시

  • UniTask.RunOnThreadPool() ❌ → WebGL에서는 사용 불가
  • await Task.Delay(1000); ❌ → 대신 UniTask.Delay() 사용
  • UniTask.Yield(PlayerLoopTiming.Background) ❌ → 대신 Update 사용
  • async void ❌ → async UniTask 또는 async Task 사용
  • UnityWebRequest 사용 시 CORS 문제 주의

 

 

Posted by 아기곰푸우
,

c# 서버에서 코루틴과 await을 사용시 장단점

 

 

코루틴 만 사용하면 빠름
 await 코루틴 같이 사용하면 느림 50 cpu
 await 만 사용하면 14 cpu
 ai

 

싱글쓰레드처럼 처리하기 위해선 코루틴이 좋아보임이지만 결과값 리턴 하는 경우 좀 지저분해짐

 

Posted by 아기곰푸우
,

https://kylewbanks.com/blog/unity3d-panning-and-pinch-to-zoom-camera-with-touch-and-mouse-input

Posted by 아기곰푸우
,

https://assetstore.unity.com/packages/tools/utilities/asset-hunter-pro-135296

Posted by 아기곰푸우
,

https://flaxengine.com/

 

Flax - Flax Engine

Best development performance out there Unleash your creativity and be more productive. With Flax you can boost your game development and bring it to another level. We’ve created tools that are slim and agile. No Read more…

flaxengine.com

 

 출시 시 4%를 지불 (분기당 처음 $250,000 이상)

 

c# 언어 지원

Posted by 아기곰푸우
,

기원 1년부터 표시 가능

그 이전은 별도 자료형을 사용할것

다른 언어의 경우 처리가 다르므로 기원전 표시의 경우 확인이 필요

 

Posted by 아기곰푸우
,