Get it on Google Play


Wm뮤 :: 'Unity' 카테고리의 글 목록

블로그 이미지
불펌때문에 드래그 방지 건것가지고
99% 다 공유되는 지식 가져와서 쓰는 글 아니냐 누가 보면 자기 지식 훔쳐가는줄 자기도 다 베껴온거일텐데
같은 소리 할거면 꾸역꾸역 블로그 찾아오지 말고 AI나 쓰쇼.
세상에 없는게 많아서 손수 연구하고 정리해줬더니 이런 소리나 들어야 합니까?
모카쨩
@ahzkwid

Recent Comment

Archive


2025. 7. 3. 01:48 Unity/C#

 

먼저 구독관리를 해야 활성화 된다

 

 

 

 

 

1. 주석으로 코드 생성

 

주석으로 만들 코드를 설명하고 엔터치면 코드가 나온다

 

 

이 상태에서 TAP을 누르면 입력된다

 

 

 

 

 

2. 질문하기

 

 

 

 

질문 입력

 

 

해당되는 코드 입력

 

 

 

전송

 

 

근데 너무 빡대가리라 GPT 쓰는게 낫다

 

'Unity > C#' 카테고리의 다른 글

SharpPcap을 이용한 패킷분석 프로그램 제작  (0) 2025.06.24
유니티 오브젝트 경로 관련  (0) 2024.08.23
OnSceneGUI 관련코드  (0) 2024.07.11
posted by 모카쨩
2025. 6. 24. 16:15 Unity/C#

 

 

 

 

 

 

먼저 와이어샤크를 통해 패킷분석을 먼저 한다

그래야 좀 편하다

https://wmmu.tistory.com/entry/%EC%99%80%EC%9D%B4%EC%96%B4%EC%83%A4%ED%81%AC%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%ED%8C%A8%ED%82%B7%EB%B6%84%EC%84%9D

 

와이어샤크를 이용한 패킷분석

와이어샤크를 깐다https://www.wireshark.org/download.html Wireshark • DownloadWireshark: The world's most popular network protocol analyzerwww.wireshark.org 그다음 찾고자 하는 패킷을 필터링 하기위해 IP와 포트를 얻어낼것

wmmu.tistory.com

 

 

 

 

 

 

 

 

 

 

 

윈폼 프로젝트 셋업을 한다

 

SharpPcap Nuget을 설치

 

샘플들은 이곳에서 볼수있다

https://github.com/dotpcap/sharppcap

 

GitHub - dotpcap/sharppcap: Official repository - Fully managed, cross platform (Windows, Mac, Linux) .NET library for capturing

Official repository - Fully managed, cross platform (Windows, Mac, Linux) .NET library for capturing packets - dotpcap/sharppcap

github.com

 

 

 

 

샘플코드

https://gist.github.com/ahzkwid/f0d9f01fdf41e7d3cfd4f6ace0438f92

using System.Diagnostics;
using SharpPcap;
using SharpPcap.LibPcap;

namespace Ahzkwid
{
    public class PacketCapture
    {
        private LibPcapLiveDevice[] devices;

        public PacketCapture()
        {

            var devices = LibPcapLiveDeviceList.Instance.ToList();

            // IP가 있는 장치만 필터링해서 재할당
            //devices = devices.FindAll(dev => dev.Addresses.Any(a => a.Addr.ipAddress.AddressFamily == AddressFamily.InterNetwork));

            devices = devices
            .FindAll(dev =>
            {
                var lowerName = dev.Description.ToLower();
                if (lowerName.Contains("loopback") && lowerName.Contains("capture"))
                {
                    return false;
                }
                return true;
            });

            Debug.WriteLine("장치 목록");
            for (int i = 0; i < devices.Count; i++)
            {
                var device = devices[i];
                var address = device.Addresses.Select(a => a.Addr);
                Debug.WriteLine($"[{i}] {device.Description} - Address: {string.Join(", ", address)}");
            }

            this.devices = devices.ToArray();
        }

        public void Start()
        {
            Debug.WriteLine("패킷 캡처 시작.");
            foreach (var device in devices)
            {
                device.Open(DeviceModes.Promiscuous, 1000);
                device.OnPacketArrival += (sender, e) =>
                {
                    var data = e.GetPacket().Data;
                    Debug.WriteLine($"{System.DateTime.Now} : {BitConverter.ToString(data).Replace("-", " ")}");
                };
                device.StartCapture();
            }
        }

        public void Stop()
        {
            foreach (var device in devices)
            {
                device.StopCapture();
                device.Close();
            }
            Debug.WriteLine("패킷 캡처 종료.");
        }
    }
}

 

위 코드를 넣고

 

아래처럼 넣어주면 된다

public partial class Form1 : Form
{
    private Ahzkwid.PacketCapture packetCapture;
    public Form1()
    {
        InitializeComponent();

        packetCapture = new Ahzkwid.PacketCapture();
        packetCapture.Start();
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        packetCapture?.Stop();
    }
}

 

 

 

그러면 아래와 같이 패킷들이 나오고

입맛에 맞게 필터링을 걸거나 추출하면 된다

 

 

 

 



SharpPcap으로 만든것

https://wmmu.tistory.com/entry/%EB%AA%A8%EB%B9%84%EB%85%B8%EA%B8%B0-%ED%97%88%EC%88%98%EC%95%84%EB%B9%84-%EB%AF%B8%ED%84%B0%EA%B8%B0-%EC%82%AC%EC%9A%A9%EB%B2%95

 

모비노기 허수아비 미터기 사용법

https://www.youtube.com/watch?v=RUM0Tktf2zU 이 미터기는 허수아비에서만 사용가능하며 장비와 딜사이클 세팅을 위해 쓴다 아래 링크로 들어간다 https://github.com/zjvlwid/MobiMeter/releases Releases · zjvlwid/MobiMeterCo

wmmu.tistory.com

 

 

 

'Unity > C#' 카테고리의 다른 글

Copilot 사용법  (0) 2025.07.03
유니티 오브젝트 경로 관련  (0) 2024.08.23
OnSceneGUI 관련코드  (0) 2024.07.11
posted by 모카쨩
2024. 9. 8. 07:28 Unity

 

 

Opening file failed

Opening file 경로.meta: 지정된 경로를 찾을 수 없습니다.

 

 

 

에셋 수정툴 만들때 잘못된 GUID 입력으로 발생한다

 

 

 

문제가 되는 에셋과 Library 폴더 삭제로 해결가능하다

 

 

 

 

 

그런데 라이브러리 통째로 지우는건 시간이 오래 걸려서 위 폴더만 지워도 된다

 

 

'Unity' 카테고리의 다른 글

LTCGI  (0) 2024.09.06
유니티 Assembly Definition Asset  (0) 2024.04.16
게임개발용 부하테스트 2024  (0) 2024.02.27
posted by 모카쨩
2024. 9. 6. 10:08 Unity

 

 

 

https://ltcgi.dev/#Attribution

 

✨ About LTCGI | LTCGI Documentation

LTCGI is an optimized plug-and-play realtime area light solution using the linearly transformed cosine algorithm for standalone Unity and VRChat. Free to use with attribution. It can utilize the Unity build-in lightmapper or Bakery for realistic shadows on

ltcgi.dev

 

 

화면자체가 라이팅이 되는 시스템

 

영화관같은거 만들때 쓰지 않을까 

 

 

'Unity' 카테고리의 다른 글

Opening file failed 에러  (0) 2024.09.08
유니티 Assembly Definition Asset  (0) 2024.04.16
게임개발용 부하테스트 2024  (0) 2024.02.27
posted by 모카쨩
2024. 8. 23. 06:30 Unity/C#


Root를 제외한 경로반환

v1 ~ v3

더보기


가령 Root/armature/Hips는 /armature/Hips가 된다

string ArmaturePath(Transform bone)
{
    var rootName = bone.transform.root.name;
    var hierarchyPath = bone.transform.GetHierarchyPath();
    return hierarchyPath.Substring(rootName.Length, hierarchyPath.Length - rootName.Length);
}

 

 


Root를 제외한 경로반환 v2 (상대경로)

인자를 하나 더 받고 안정성을 높였다

https://gist.github.com/ahzkwid/c89b626c0e7bace5cc317901b524672e

static string RelativePath(Transform target, Transform root = null)
{
    var rootName = "";
    var hierarchyPath = "";


    if (root != null)
    {
        try
        {
            rootName = SearchUtils.GetHierarchyPath(root.gameObject, false);

        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex);
            Debug.LogError(root.ToString() + "nothing root");
            //Debug.LogError(bone.name + "는 root가 없음");
            throw;
        }
    }
    try
    {
        //hierarchyPath = bone.GetHierarchyPath();
        hierarchyPath = SearchUtils.GetHierarchyPath(target.gameObject, false);
    }
    catch (System.Exception ex)
    {
        Debug.LogError(ex);
        Debug.LogError(target.ToString() + "nothing GetHierarchyPath");
        throw;
    }

    var startIndex = rootName.Length;

    return hierarchyPath.Substring(startIndex, hierarchyPath.Length - startIndex);
}

 

v3

static string RelativePath(Transform target, Transform root = null)
{
    var rootName = "";
    var hierarchyPath = "";


    if (root != null)
    {
        try
        {
            rootName = SearchUtils.GetHierarchyPath(root.gameObject, false);

        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex);
            Debug.LogError(root.ToString() + "nothing root");
            //Debug.LogError(bone.name + "는 root가 없음");
            throw;
        }
    }
    try
    {
        //hierarchyPath = bone.GetHierarchyPath();
        hierarchyPath = SearchUtils.GetHierarchyPath(target.gameObject, false);
    }
    catch (System.Exception ex)
    {
        Debug.LogError(ex);
        Debug.LogError(target.ToString() + "nothing GetHierarchyPath");
        throw;
    }

    var startIndex = rootName.Length;

    if (rootName.Length > hierarchyPath.Length)
    {
        Debug.LogWarning("rootName.Length > hierarchyPath.Length");
        Debug.LogWarning($"{rootName} > {hierarchyPath}");
        return null;
    }

    if (hierarchyPath.Substring(0, rootName.Length) != rootName)
    {
        Debug.LogWarning("hierarchyPath.Substring(0, rootName.Length) != rootName");
        Debug.LogWarning($"{rootName} != {hierarchyPath}.Substring(0, rootName.Length)");
        return null;
    }

    try
    {
        return hierarchyPath.Substring(startIndex, hierarchyPath.Length - startIndex);
    }
    catch (System.Exception ex)
    {
        Debug.LogError(ex);
        Debug.LogError($"{hierarchyPath} - {rootName}");
        throw;
    }
}

 

 

v4

경우에 따라 앞에 슬래시는 없애도 된다

var relativePath = "/"+Path.GetRelativePath(rootpath, path);

 

 

 

 

 

 

하이어라키 경로 반환

var path = SearchUtils.GetHierarchyPath(gameObject, false);

 

 

 

패스 병합

Replace 붙은 이유는 유니티는 '/'를 쓰는데 일부 로직에서 '\'를 인식 못하기 때문

var path = Path.Join(parentPath, childPath).Replace("\\", "/");

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

'Unity > C#' 카테고리의 다른 글

SharpPcap을 이용한 패킷분석 프로그램 제작  (0) 2025.06.24
OnSceneGUI 관련코드  (0) 2024.07.11
유니티 라이트 레졸루션 개별설정  (0) 2024.05.12
posted by 모카쨩
2024. 7. 11. 19:30 Unity/C#

 

 

 

 

 

OnDrawGizmos처럼 상시동작하는점이 비슷하지만

OnDrawGizmos는 기즈모 드로우 옵션이 켜져있을때에만 동작하므로

기능코드는 가급적 OnSceneGUI에 넣는것이 좋다

 

 

 

1. Static에서 FindObjectsOfType를 이용해 가져와서 처리하는 방식

gist : https://gist.github.com/ahzkwid/3294e9d4cf3980ae2d1c135123db145c

public class SampleClass : MonoBehaviour
{
  static void OnSceneGUI(SceneView sceneView)
  {
      foreach (var sampleClass in FindObjectsOfType<SampleClass>())
      {
          if (sceneView.camera != null)
          {
              var sceneCamera = sceneView.camera;
              //CameraCode
          }
          //otherCode
      }
  }
}
//OtherSample: https://gist.github.com/ahzkwid/6647d3aec625afe96c54bb38b2671c72

 

 


2. SceneView.duringSceneGui에서 이벤트를 받는 방식

gist : https://gist.github.com/ahzkwid/315febfe26ef88adfa537bcfd6f6d49e

이 방식은 가볍지만 안정성은 1번에 비해서는 떨어진다

유니티 에디터 버그로 인해 Enable과 Disable이 제대로 호출 안 되거나 하는경우

이벤트가 중복호출되거나 등록 실패하는등...

일반적으로는 이 방식을 쓰고 무조건 동작해야 하는 너무 중요한 코드는 위방식을 쓰는게 좋다

[ExecuteInEditMode]
public class SampleClass : MonoBehaviour
{
    void OnEnable()
    {
        SceneView.duringSceneGui += OnSceneGUI;
    }

    void OnDisable()
    {
        SceneView.duringSceneGui -= OnSceneGUI;
    }
    void OnSceneGUI(SceneView sceneView)
    {
        //code
    }
}

 

 

 

 

 

 

 

 

3. EditorApplication.hierarchyWindowItemOnGUI 혼합예제

원문링크 : https://forum.unity.com/threads/solved-how-to-start-draganddrop-action-so-that-sceneview-and-hierarchy-accept-it-like-with-prefabs.822531/

아래 코드는 내가 만든게 아니고 위 링크에서 가져와 간소화 한것일뿐이다

[ExecuteInEditMode]
public class SampleClass : MonoBehaviour
{
     void OnEnable()
    {
        SceneView.duringSceneGui += OnSceneGUI;
        EditorApplication.hierarchyWindowItemOnGUI += OnHierarchyGUI;
    }

     void OnDisable()
    {
        SceneView.duringSceneGui -= OnSceneGUI;
        EditorApplication.hierarchyWindowItemOnGUI -= OnHierarchyGUI;
    }
     void OnSceneGUI(SceneView obj)
    {
        HandleDragAndDropEvents();
    }

     void OnHierarchyGUI(int instanceID, Rect selectionRect)
    {
        HandleDragAndDropEvents();
    }
     void HandleDragAndDropEvents()
    {
        if (Event.current.type == EventType.DragUpdated)
        {
            OnDragUpdated();
        }
        if (Event.current.type == EventType.DragPerform)
        {
            OnDragPerform();
        }
    }
    void OnDragUpdated()
    {
        Debug.Log("OnDragUpdated()");
    }
    void OnDragPerform()
    {
        Debug.Log("OnDragPerform()");
    }
}

 

 

 

 

 

 

 

 

 

 

 

 

 

'Unity > C#' 카테고리의 다른 글

유니티 오브젝트 경로 관련  (0) 2024.08.23
유니티 라이트 레졸루션 개별설정  (0) 2024.05.12
유니티 프리팹 드래그 드랍  (0) 2024.05.09
posted by 모카쨩
2024. 5. 12. 12:01 Unity/C#

 

 

 

 

 

 

 

 

 

 

 

유니티 2022.3.22.f1 이후의 경우

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


유니티 2022.3.22.f1 이전의 경우는 아래 스크립트 적용 

 

 

 

SettingLightResolution.unitypackage
0.00MB

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExecuteAlways]
public class SettingLightResolution : MonoBehaviour
{
    public Light light;
    public int resolution = 256;
    // Start is called before the first frame update
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        if (light==null)
        {
            return;
        }
        light.shadowCustomResolution = resolution;
#if UNITY_EDITOR
        UnityEditor.EditorUtility.SetDirty(light);
#endif
    }
}



어쩌다보니 만들게 됨

 

 

 

 

 

 

 

 

'Unity > C#' 카테고리의 다른 글

OnSceneGUI 관련코드  (0) 2024.07.11
유니티 프리팹 드래그 드랍  (0) 2024.05.09
AutomaticShadowDistance  (0) 2024.04.18
posted by 모카쨩
2024. 5. 9. 11:32 Unity/C#

 

 

 

 

원문링크 : 

https://forum.unity.com/threads/solved-how-to-start-draganddrop-action-so-that-sceneview-and-hierarchy-accept-it-like-with-prefabs.822531/

 

[Solved] How to start DragAndDrop action so that SceneView and Hierarchy accept it like with prefabs

Edit: Solution below. I'm building a level design tool which shows a list of prefabs in a custom editor window and lets users drag and drop these...

forum.unity.com

 

 

이 코드는 내가 만든게 아니고 위 링크에서 가져와 간소화 한것일뿐이다

 void OnEnable()
{
    SceneView.duringSceneGui += OnSceneGUI;
    EditorApplication.hierarchyWindowItemOnGUI += OnHierarchyGUI;
}

 void OnDisable()
{
    SceneView.duringSceneGui -= OnSceneGUI;
    EditorApplication.hierarchyWindowItemOnGUI -= OnHierarchyGUI;
}
 void OnSceneGUI(SceneView obj)
{
    HandleDragAndDropEvents();
}

 void OnHierarchyGUI(int instanceID, Rect selectionRect)
{
    HandleDragAndDropEvents();
}
 void HandleDragAndDropEvents()
{
    if (Event.current.type == EventType.DragUpdated)
    {
        OnDragUpdated();
    }
    if (Event.current.type == EventType.DragPerform)
    {
        OnDragPerform();
    }
}
void OnDragUpdated()
{
    Debug.Log("OnDragUpdated()");
}
void OnDragPerform()
{
    Debug.Log("OnDragPerform()");
}

 

 

 

아바타 툴 만들때 사용되었다

 

 

 

 

 

'Unity > C#' 카테고리의 다른 글

유니티 라이트 레졸루션 개별설정  (0) 2024.05.12
AutomaticShadowDistance  (0) 2024.04.18
c# Dictionary(딕셔너리) 관련  (0) 2024.03.19
posted by 모카쨩