【Unity 확장】Unity 에디터로 오미쿠지가 당기고 싶은 【소재】

소개



Unity에서 오미 복권을 당기고 싶었기 때문에 만들었습니다.

만든 것에 대해



모든 창에 오미쿠지가 표시됩니다.


소스 코드



텍스트 표시 주위의 처리는 대초원 클래스( htps : // 기 st. 기주 b. 코m/안짱828/7970330 ) 를 참고로 했습니다.

EditorOmikuji.cs
using UnityEngine;
using UnityEditor;
using System.Collections;

public class EditorOmikuji
{
    static EditorWindow[] windows;
    static string text;

    [MenuItem("Omikuji/Omikuji")]
    static void Omikuji()
    {
        text = texts[Random.Range(0, texts.Length)];
        windows = Resources.FindObjectsOfTypeAll<EditorWindow> ();
        EditorApplication.update += () => {
            if (windows.Length != 0) {
                try {
                    windows [0].Focus ();
                    windows [0].ShowNotification (new GUIContent (text));
                    ArrayUtility.RemoveAt (ref windows, 0);
                } catch (System.NullReferenceException) {
                }
            }
        };
    }

    static readonly string[] texts = new string []
    {
        "大吉",
        "中吉",
        "小吉",
        "吉",
        "末吉",
        "凶",
        "大凶"
    };
}

대흉이 나오면 조금 충격 ...

좋은 웹페이지 즐겨찾기