Пример #1
0
    public static void CreateImage(int w, int h)
    {
        string path = EditorUtility.SaveFilePanel("Create UPAImage",
                                                  "Assets/", "Pixel Image.asset", "asset");

        if (path == "")
        {
            return;
        }

        path = FileUtil.GetProjectRelativePath(path);

        UPAImage img = ScriptableObject.CreateInstance <UPAImage>();

        AssetDatabase.CreateAsset(img, path);

        AssetDatabase.SaveAssets();

        img.Init(w, h);
        EditorUtility.SetDirty(img);
        UPAEditorWindow.CurrentImg = img;

        EditorPrefs.SetString("currentImgPath", AssetDatabase.GetAssetPath(img));

        if (UPAEditorWindow.window != null)
        {
            UPAEditorWindow.window.Repaint();
        }
        else
        {
            UPAEditorWindow.Init();
        }

        img.gridSpacing = 10 - Mathf.Abs(img.width - img.height) / 100f;
    }
Пример #2
0
    public static UPAImage CreateUPAImage(int w, int h)
    {
        UPAImage img = ScriptableObject.CreateInstance <UPAImage>();

        img.Init(w, h);
        img.gridSpacing = 10 - Mathf.Abs(img.width - img.height) / 100f;

        return(img);
    }
Пример #3
0
    static UPAImage customCreateImage(int w, int h, bool isTemplate)
    {
        //TODO: want to pass in the same path that the image was pulled from, so you don't have to navigate back
        string path = EditorUtility.SaveFilePanel("Create UPAImage",
                                                  "Assets/", "Pixel Image.asset", "asset");

        if (path == "")
        {
            return(null);
        }

        Debug.Log("creating custom image");
        Debug.Log(path);

        path = FileUtil.GetProjectRelativePath(path);
        Debug.Log(path);

        UPAImage img = ScriptableObject.CreateInstance <UPAImage>();

        AssetDatabase.CreateAsset(img, path);

        AssetDatabase.SaveAssets();

        img.Init(w, h);
        EditorUtility.SetDirty(img);



        if (isTemplate)
        {
            EditorPrefs.SetString("templateImgPath", AssetDatabase.GetAssetPath(img));
            UPAEditorWindow.TemplateImage = img;
        }
        else
        {
            EditorPrefs.SetString("currentImgPath", AssetDatabase.GetAssetPath(img));
            UPAEditorWindow.CurrentImg = img;
        }

        if (UPAEditorWindow.window != null)
        {
            UPAEditorWindow.window.Repaint();
        }
        else
        {
            UPAEditorWindow.Init();
        }

        img.gridSpacing = 10 - Mathf.Abs(img.width - img.height) / 100f;
        return(img);
    }