示例#1
0
        void GatherSaveables()
        {
            var gos = AssetDatabase.FindAssets("t:GameObject");

            var gatheredCount = 0;

            for (var i = 0; i < gos.Length; i++)
            {
                var path = AssetDatabase.GUIDToAssetPath(gos[i]);
                var go   = AssetDatabase.LoadAssetAtPath <GameObject>(path);

                if (go.GetComponent <Saveable>())
                {
                    if (assetMap.Map.Find(mp => mp.Prefab == go) != null)
                    {
                        continue;
                    }

                    var mappedPrefab = new MappedPrefab();
                    mappedPrefab.Prefab = go;
                    mappedPrefab.UpdateId();

                    assetMap.Map.Add(mappedPrefab);

                    gatheredCount++;
                }
            }

            Debug.Log("[Pluto Save] Gathered " + gatheredCount + " new saveable prefabs.");

            if (gatheredCount > 0)
            {
                EditorUtility.SetDirty(target);
            }
        }
示例#2
0
        void DrawMapped(MappedPrefab mappedPrefab)
        {
            var saveable = mappedPrefab.Prefab.GetComponent <Saveable>();

            var prevColor = GUI.color;

            if (!saveable)
            {
                GUI.color = Color.red;
            }
            else if (saveable.PrefabId != mappedPrefab.Id)
            {
                GUI.color = Color.yellow;
            }

            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            GUILayout.BeginVertical();

            GUILayout.Label(mappedPrefab.Prefab.name, EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Prefab id: ", GUILayout.MaxWidth(60));

            var prevEnabled = GUI.enabled;

            GUI.enabled = false;
            GUILayout.TextField(mappedPrefab.Id, GUILayout.MinWidth(120));
            GUI.enabled = prevEnabled;
            GUILayout.EndHorizontal();

            mappedPrefab.Prefab =
                (GameObject)EditorGUILayout.ObjectField(mappedPrefab.Prefab, typeof(GameObject), false);

            GUILayout.EndVertical();

            GUILayout.BeginVertical(GUILayout.Width(48));
            if (GUILayout.Button("Remove"))
            {
                toRemove.Add(mappedPrefab);
            }
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUI.color = prevColor;
        }
示例#3
0
        void AddPrefab(AssetMap assetMap, GameObject prefab)
        {
            for (var i = 0; i < assetMap.Map.Count; i++)
            {
                if (assetMap.Map[i].Prefab == prefab)
                {
                    Debug.LogWarning("Same prefab already added to the Map");
                    return;
                }
            }

            var mappedPrefab = new MappedPrefab();

            mappedPrefab.Prefab = prefab;
            mappedPrefab.UpdateId();

            assetMap.Map.Add(mappedPrefab);

            EditorUtility.SetDirty(target);
        }