Exemplo n.º 1
0
    private void DrawSaveGUI(ref bool dirty)
    {
        EditorGUILayout.BeginVertical(GUI.skin.box);

        EditorGUILayout.LabelField("Save state:");

        saveSettings = EditorGUILayout.Toggle("Settings", saveSettings);

        if (allowSaveTexture)
        {
            saveTexture = EditorGUILayout.Toggle("Texture", saveTexture);
        }

        saveControl = EditorGUILayout.Toggle("Control", saveControl);
        saveMarkers = EditorGUILayout.Toggle("Markers", saveMarkers);

        if (allowSaveMarkers3D)
        {
            saveMarkers3D = EditorGUILayout.Toggle("Markers 3D", saveMarkers3D);
        }
        if (allowSaveLocationService)
        {
            saveLocationService = EditorGUILayout.Toggle("Location Service", saveLocationService);
        }

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Save state"))
        {
            if (allowSaveTexture && saveTexture)
            {
                api.Save();

                string path = AssetDatabase.GetAssetPath(api.texture);
                File.WriteAllBytes(path, api.texture.EncodeToPNG());
                AssetDatabase.Refresh();
            }

            OnlineMapsXML prefs = new OnlineMapsXML("OnlineMaps");

            if (saveSettings)
            {
                api.SaveSettings(prefs);
            }
            if (saveControl)
            {
                api.GetComponent <OnlineMapsControlBase>().SaveSettings(prefs);
            }
            if (saveMarkers)
            {
                api.SaveMarkers(prefs);
            }
            if (allowSaveMarkers3D && saveMarkers3D)
            {
                api.GetComponent <OnlineMapsControlBase3D>().SaveMarkers3D(prefs);
            }
            if (allowSaveLocationService && saveLocationService)
            {
                api.GetComponent <OnlineMapsLocationService>().Save(prefs);
            }

            OnlineMapsPrefs.Save(prefs.outerXml);

            ResetSaveSettings();
            dirty = true;
        }

        if (GUILayout.Button("Cancel", GUILayout.ExpandWidth(false)))
        {
            ResetSaveSettings();
            dirty = true;
        }

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.EndVertical();
    }