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(); } }
public static void MakeCustomPixel(this SpriteRenderer _sp, float width, float height) { CustomSprite cache_sprite = _sp.GetComponent <CustomSprite>(); if (cache_sprite != null && cache_sprite.enabled) { Vector2 val = new Vector2(width, height); cache_sprite.customPixelVector = val; cache_sprite.CustomPixel(); } else { Debug.LogError("No Custom Sprite Component Found.."); } }