Get it on Google Play


Wm뮤 :: 'Unity' 카테고리의 글 목록 (6 Page)

블로그 이미지
가끔 그림그리거나 3D모델링하거나
취미로 로봇만드는
전자과 게임프로그래머 (퇴사함)
2022.3.22f1 주로 사용
모카쨩
@Ahzkwid

Recent Comment

Archive


'Unity'에 해당되는 글 186건

  1. 2022.04.30 유니티 csv 에셋
  2. 2022.04.24 유니티 차트
  3. 2022.04.23 유니티 Log 확인 에셋
  4. 2022.04.02 유니티 문자인식
  5. 2022.03.15 유니티 Mesh Boolean
  6. 2022.03.06 csv 사용법
  7. 2022.02.25 유니티 IOS 인터페이스
  8. 2022.02.12 유니티 텍스처 관련
2022. 4. 30. 11:46 Unity

 

 

 

https://assetstore.unity.com/packages/tools/integration/csv-serialize-135763

 

CSV Serialize | 기능 통합 | Unity Asset Store

Use the CSV Serialize from VisualWorks on your next project. Find this integration tool & more on the Unity Asset Store.

assetstore.unity.com

 

 

 

 

 

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

public class Demo : MonoBehaviour
{

    public Test[] tests;
    [System.Serializable]
    public class Test
    {
        public int num = 0;
        public string name = "";
    }
        // Start is called before the first frame update
    void Start()
    {

        var csv = "num,name\n0,\"mom\"\r\n1,dad\n\"2\",\"me\"\n\"3\",\"한국어\"";
        tests = CSVSerializer.Deserialize<Test>(csv);
        var list = CSVSerializer.ParseCSV(csv);
        for (int x = 0; x < list.Count; x++)
        {
            for (int y = 0; y < list[x].Length; y++)
            {
                Debug.Log($"[{x}][{y}]{list[x][y]}");
            }
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

 

 

잘된다

'Unity' 카테고리의 다른 글

유니티 창위치 설정  (0) 2022.06.18
유니티 차트  (0) 2022.04.24
유니티 Log 확인 에셋  (0) 2022.04.23
posted by 모카쨩
2022. 4. 24. 01:16

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

2022. 4. 23. 12:18 Unity

 

 

Log Viewer

 

더보기

 

 

https://assetstore.unity.com/packages/tools/integration/log-viewer-12047

 

Log Viewer | 기능 통합 | Unity Asset Store

Use the Log Viewer from dreammakersgroup on your next project. Find this integration tool & more on the Unity Asset Store.

assetstore.unity.com

 

 

이녀석을 디버그빌드에서만 사용하게 온오프걸면 된다

반시계로 마우스를 돌리면 활성화된다

 

단점은 닫기버튼이 작은화면에선 안 보이고 뒤쪽 UGUI도 눌려버려서 기분 더럽다

 

 

 

 

In-game Debug Console

 

 

 

'Unity' 카테고리의 다른 글

유니티 차트  (0) 2022.04.24
유니티 문자인식  (0) 2022.04.02
유니티 Mesh Boolean  (0) 2022.03.15
posted by 모카쨩
2022. 4. 2. 12:23 Unity

 

 

 

https://github.com/Neelarghya/tesseract-unity

 

GitHub - Neelarghya/tesseract-unity: Standalone OCR plugin for Unity using Tesseract

Standalone OCR plugin for Unity using Tesseract. Contribute to Neelarghya/tesseract-unity development by creating an account on GitHub.

github.com

 

 

 

 

Main Scene을 열어서 돌려보면 된다

StreamingAssets는 경로참조를 하기 때문에 최상단에 있어야한다

 

 

 

이미지는 저걸 바꾸면 됨

간단하게 쓰려면 Display Text에서 text를 추출해도 된다

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

결과물

 

'Unity' 카테고리의 다른 글

유니티 Log 확인 에셋  (0) 2022.04.23
유니티 Mesh Boolean  (0) 2022.03.15
유니티 IOS 인터페이스  (0) 2022.02.25
posted by 모카쨩
2022. 3. 15. 15:00

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

2022. 3. 6. 13:22 Unity/C#

 

 

 

 

 

 

 

혹은 아래걸 사용

https://wmmu.tistory.com/entry/%EC%9C%A0%EB%8B%88%ED%8B%B0-csv-%EC%97%90%EC%85%8B

 

유니티 csv 에셋

https://assetstore.unity.com/packages/tools/integration/csv-serialize-135763 CSV Serialize | 기능 통합 | Unity Asset Store Use the CSV Serialize from VisualWorks on your next project. Find this integration tool & more on the Unity Asset Store. assetsto

wmmu.tistory.com

 

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

Path 연산  (0) 2023.09.09
Windows DLL경로  (0) 2022.02.12
유니티 폴리곤 처리  (0) 2022.02.10
posted by 모카쨩
2022. 2. 25. 10:19

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

2022. 2. 12. 04:53 Unity

 

SetPixel


public Texture2D texture2D;
void Start()
{
    texture2D = new Texture2D(512,1);
    for (int i = 0; i < 512; i++)
    {
        texture2D.SetPixel(i,0, new Color(1, (float)i / 512, 0, 0.25f));
    }
    texture2D.Apply();
}

 

SetPixels


public Texture2D texture2D;
void Start()
{
    var colors = new Color[512];
    for (int i = 0; i < 512; i++)
    {
        colors[i] = new Color(1, (float)i / 512, 0, 0.25f);
    }
    texture2D = new Texture2D(512, 1);
    texture2D.SetPixels(0, 0, texture2D.width, texture2D.height, colors);
    texture2D.Apply();
}

 

 

 

 

픽셀 불러오기

var pixels = tex.GetPixels(0, 0, tex.width, tex.height);
for (int x = 0; x < tex.width; x++)
{
    for (int y = 0; y < pixels.Length / tex.width; y++)
    {
        var index = y * tex.width + x;
        var pixel = pixels[index];
    }
}

 

 

 

렌더텍스처 픽셀 가져오기

원문코드는 이곳에서 가져왔다 https://docs.unity3d.com/kr/530/ScriptReference/RenderTexture-active.html

    static public Texture2D GetRTPixels(RenderTexture rt)
    {

        // Remember currently active render texture
        RenderTexture currentActiveRT = RenderTexture.active;

        // Set the supplied RenderTexture as the active one
        RenderTexture.active = rt;

        // Create a new Texture2D and read the RenderTexture image into it
        Texture2D tex = new Texture2D(rt.width, rt.height);
        tex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0);

        // Restorie previously active render texture
        RenderTexture.active = currentActiveRT;
        return tex;
    }

위 코드 사용 예제

var texture = GetRTPixels(renderTexture);
var pixels = texture.GetPixels(0, 0, texture.width, texture.height, miplevel : 0);

 

 

 

Texture2D 빈 가장자리 제거

    static public Texture2D TrimTexture(Texture2D texture)
    {
        return TrimTexture(texture, Vector2.zero);
    }
    static public Texture2D TrimTexture(Texture2D texture,Vector2 padding)
    {
        var rect = new Rect(0, 0, texture.width, texture.height);

        {
            var pixels = texture.GetPixels(0, 0, texture.width, texture.height);
            //x
            for (int x = 0; x < texture.width; x++)
            {
                for (int y = 0; y < pixels.Length / texture.width; y++)
                {
                    var index = x + y * texture.width;
                    var pixel = pixels[index];
                    if (pixel.a > 0)
                    {
                        rect.x = x;
                        break;
                    }
                }
                if (rect.x != 0)
                {
                    break;
                }
            }

            //y
            for (int y = 0; y < pixels.Length / texture.width; y++)
            {
                for (int x = 0; x < texture.width; x++)
                {
                    var index = x + y * texture.width;
                    var pixel = pixels[index];
                    if (pixel.a > 0)
                    {
                        rect.y = y;
                        break;
                    }
                }
                if (rect.y != 0)
                {
                    break;
                }
            }

            //width
            for (int x = texture.width - 1; x >= 0; x--)
            {
                for (int y = pixels.Length / texture.width - 1; y >= 0; y--)
                {
                    var index = x + y * texture.width;
                    var pixel = pixels[index];
                    if (pixel.a > 0)
                    {
                        rect.width = x - rect.x;
                        break;
                    }
                }
                if (rect.width != texture.width)
                {
                    break;
                }
            }

            //height
            for (int y = pixels.Length / texture.width - 1; y >= 0; y--)
            {
                for (int x = texture.width - 1; x >= 0; x--)
                {
                    var index = x + y * texture.width;
                    var pixel = pixels[index];
                    if (pixel.a > 0)
                    {
                        rect.height = y - rect.y;
                        break;
                    }
                }
                if (rect.height != texture.height)
                {
                    break;
                }
            }
        }
        {
            var pixels = texture.GetPixels((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
            var trimTexture = new Texture2D((int)rect.width+ (int)padding.x*2, (int)rect.height + (int)padding.y * 2);
            var defaultPixels = new Color[trimTexture.width * trimTexture.height];
            System.Array.ConvertAll(defaultPixels,x=>new Color(0,0,0,0));
            trimTexture.SetPixels(0, 0, trimTexture.width, trimTexture.height, defaultPixels);
            trimTexture.SetPixels((int)padding.x, (int)padding.y, (int)rect.width, (int)rect.height, pixels);
            trimTexture.Apply();
            return trimTexture;
        }
    }

 

 

 

RGB만 바꾸기

만들고 보니 쓸모가 없어졌네


    /// <summary>
    /// rgb만 바꾸고 a는 그냥 놔둠
    /// </summary>
    /// <param name="texture"></param>
    /// <param name="color"></param>
    static public void ChangeRGB(Texture2D texture,Color color)
    {
        var pixels = texture.GetPixels(0, 0, texture.width, texture.height);
        for (int x = 0; x < texture.width; x++)
        {
            for (int y = 0; y < pixels.Length / texture.width; y++)
            {
                var index = x + y * texture.width;
                pixels[index].r = color.r;
                pixels[index].g = color.g;
                pixels[index].b = color.b;
            }
        }
        texture.SetPixels(0, 0, texture.width, texture.height, pixels);
    }

 

 

 

 

 

 

SaveRenderWindow

https://gist.github.com/ahzkwid/10974a8f59c215ea02a9e5a35e533f66

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

#if UNITY_EDITOR
//https://gist.github.com/ahzkwid/10974a8f59c215ea02a9e5a35e533f66

using UnityEditor;

[InitializeOnLoad]
class SaveRenderWindow : EditorWindow
{
    public RenderTexture targetRenderTexture;

    [UnityEditor.MenuItem("Ahzkwid/" + nameof(SaveRenderWindow))]
    public static void Init()
    {
        GetWindow<SaveRenderWindow>(false, nameof(SaveRenderWindow));
    }
    SerializedObject serializedObject;
    void OnGUI()
    {
        if (serializedObject == null)
        {
            serializedObject = new SerializedObject(this);
        }
        serializedObject.Update();
        {
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(targetRenderTexture)));
        }
        serializedObject.ApplyModifiedProperties();
        if (GUILayout.Button("Save"))
        {
            SaveRenderTexture();
        }
    }
    static public Texture2D GetRTPixels(RenderTexture rt)
    {
        //https://docs.unity3d.com/kr/530/ScriptReference/RenderTexture-active.html
        RenderTexture currentActiveRT = RenderTexture.active;
        RenderTexture.active = rt;

        Texture2D tex = new Texture2D(rt.width, rt.height);
        tex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0);
        RenderTexture.active = currentActiveRT;
        return tex;
    }
    public void SaveRenderTexture()
    {
        if (targetRenderTexture != null)
        {
            var fileName = $"{System.DateTime.Now.Ticks}";
            var folderPath = $"{Application.persistentDataPath}";
            var filePath = $"{folderPath}/{fileName}.png";

            if (System.IO.Directory.Exists(folderPath) == false)
            {
                System.IO.Directory.CreateDirectory(folderPath);
            }
            var texture2D = GetRTPixels(targetRenderTexture);
            //var texture2D = new Texture2D(targetRenderTexture.width, targetRenderTexture.height, TextureFormat.RGBA32, false);
            //texture2D.SetPixels(targetRenderTexture.GetPixels());
            var bytes = texture2D.EncodeToPNG();
            System.IO.File.WriteAllBytes(filePath, bytes);

            System.Diagnostics.Process.Start(folderPath);
        }
    }
}
#endif

 

'Unity' 카테고리의 다른 글

유니티 IOS 인터페이스  (0) 2022.02.25
유니티 안드로이드 동영상 관련자료  (0) 2022.02.11
유니티 pb stl 사용법  (0) 2022.02.08
posted by 모카쨩

저사양 유저용 블로그 진입