Exemple #1
0
        public override void OnInspectorGUI()
        {
            assetMap = target as AssetMap;

            foldout = EditorGUILayout.Foldout(foldout, "Prefabs list");

            if (foldout)
            {
                for (var i = 0; i < assetMap.Map.Count; i++)
                {
                    DrawMapped(assetMap.Map[i]);
                }

                GUILayout.Space(10);
            }

            if (toRemove.Count > 0)
            {
                for (var i = 0; i < toRemove.Count; i++)
                {
                    assetMap.Map.Remove(toRemove[i]);
                }

                EditorUtility.SetDirty(target);

                toRemove.Clear();
            }

            if (GUILayout.Button("Gather saveables from prefabs"))
            {
                GatherSaveables();
            }

            if (GUILayout.Button("Update map prefab IDs"))
            {
                assetMap.UpdateMap();
            }

            GUILayout.Space(10);

            GUILayout.Label("Add new prefab maually", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            selectedObject = EditorGUILayout.ObjectField(selectedObject, typeof(GameObject), false) as GameObject;

            var prevGUIEnabled = GUI.enabled;

            GUI.enabled = selectedObject;

            if (GUILayout.Button("Add"))
            {
                AddPrefab(assetMap, selectedObject);
            }

            GUI.enabled = prevGUIEnabled;

            GUILayout.EndHorizontal();
        }
Exemple #2
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);
        }