コード例 #1
0
    public override void OnInspectorGUI()
    {
        m_target = (CustomSprite)target;
        GUILayout.Space(10);


        EditorGUILayout.BeginHorizontal();

        m_target.customPixelVector = EditorGUILayout.Vector2Field("", m_target.customPixelVector);

        EditorGUILayout.EndHorizontal();


        if (GUILayout.Button("Custom Pixel", GUILayout.Width(90), GUILayout.Height(25)))
        {
            m_target.CustomPixel();
        }

        GUILayout.Space(10);

        if (GUILayout.Button("Make Pixel Perfect"))
        {
            m_target.PixelPerfect();
        }
    }
コード例 #2
0
    public static void MakePixelPerfect(this SpriteRenderer _sp)
    {
        CustomSprite cache_sprite = _sp.GetComponent <CustomSprite>();

        if (cache_sprite != null && cache_sprite.enabled)
        {
            cache_sprite.height = _sp.sprite.bounds.size.y * 100;
            cache_sprite.width  = _sp.sprite.bounds.size.x * 100;
            Vector2 val = new Vector2(cache_sprite.width, cache_sprite.height);
            cache_sprite.PixelPerfect();
        }
        else
        {
            Debug.LogError("No Custom Sprite Component Found..");
        }
    }