Beispiel #1
0
        public void UpdateExporterUI()
        {
            ExportDefinitionList.Clear();
            AssetList.Clear();

            UpdateHandler?.Invoke(this, null);
        }
Beispiel #2
0
        public void DeserializeFromString(string[] lines)
        {
            var selectedModels = new List <string>();

            foreach (string line in lines)
            {
                if (line.StartsWith($"{SerializePrefix} "))
                {
                    selectedModels.Add(line.Replace($"{SerializePrefix} ", ""));
                }
            }
            if (m_basicAssetsList == null)
            {
                LoadBasicAssets();
            }

            var resultList = m_basicAssetsList.Where(x => selectedModels.Contains(x) || selectedModels.Contains(x.Split(".".ToCharArray())[0])).ToList();

            LogUtils.DoLog($"IMPORTED: {resultList.Count} assets for {typeof(W)} => {resultList}");
            if (resultList.Count == 0)
            {
                AssetList.Clear();
            }
            else
            {
                AssetList = new SimpleXmlHashSet <string>(resultList);
            }
        }
Beispiel #3
0
    public static void GenerateAssetList()
    {
        list.Clear();
        var it = s_AssetDirs.GetEnumerator();

        while (it.MoveNext())
        {
            UpdateAssetList(list, string.Format("{0}/{1}", Application.dataPath.Replace("Assets", ""), it.Current));
        }

        SaveAssetList();
    }
Beispiel #4
0
        void UpgradeMaterials()
        {
            // upgrade material template assets
            var assetList = new AssetList();

            assetList.AddRange(
                AssetDatabase.FindAssets($"t:{nameof(PhysicsMaterialTemplate)}")
                .Select(guid => AssetDatabase.GUIDToAssetPath(guid))
                .Select(path => new Asset(path))
                );
            if (assetList.Count > 0)
            {
                if (IsEditable(assetList, m_Failures))
                {
                    foreach (var asset in assetList)
                    {
                        if (!IsEditable(asset, m_Failures))
                        {
                            continue;
                        }

                        // material templates are upgraded in OnEnable(), so it should be sufficient to merely load them
                        var materialTemplate = AssetDatabase.LoadAssetAtPath <PhysicsMaterialTemplate>(asset.path);
                        EditorUtility.SetDirty(materialTemplate);
                        m_Successes.AddEntry(asset.path, string.Empty);
                    }
                }
            }

            // upgrade prefabs
            assetList.Clear();
            foreach (var guid in AssetDatabase.FindAssets("t:Prefab"))
            {
                var prefabAssetPath = AssetDatabase.GUIDToAssetPath(guid);

                var prefab = AssetDatabase.LoadAssetAtPath <GameObject>(prefabAssetPath);

                var shapeComponents = prefab.GetComponentsInChildren <PhysicsShapeAuthoring>(true);
                if (shapeComponents.Length == 0)
                {
                    continue;
                }

                var asset = new Asset(prefabAssetPath);
                if (!IsEditable(asset, m_Failures))
                {
                    continue;
                }

                assetList.Add(asset);
            }

            if (assetList.Count > 0)
            {
                if (IsEditable(assetList, m_Failures))
                {
                    var upgradedAssets = new HashSet <Asset>();
                    foreach (var asset in assetList)
                    {
                        UpgradePrefabAsset(asset, assetList, upgradedAssets, m_Successes, m_Failures);
                    }
                }
            }

            // update scene objects
            EditorSceneManager.SetActiveScene(EditorSceneManager.NewScene(NewSceneSetup.EmptyScene));
            foreach (var guid in AssetDatabase.FindAssets("t:Scene"))
            {
                var scenePath = AssetDatabase.GUIDToAssetPath(guid);

                var asset = new Asset(scenePath);
                if (!IsEditable(asset, m_Failures))
                {
                    continue;
                }

                Scene scene;
                try { scene = EditorSceneManager.OpenScene(scenePath); }
                catch (Exception e)
                {
                    m_Failures.AddEntry(asset.path, $"{e.Message}\n\n{e.StackTrace}");
                    continue;
                }
                EditorSceneManager.SetActiveScene(scene);

                var succcess = true;
                if (IsEditable(new AssetList {
                    new Asset(scenePath)
                }, m_Failures))
                {
                    var upgradedAny = false;
                    foreach (
                        var sceneObject in scene.GetRootGameObjects()
                        .Where(go => go.GetComponentsInChildren <PhysicsShapeAuthoring>(true).Any())
                        )
                    {
                        try
                        {
                            UpgradePrefabInstance(sceneObject);
                            upgradedAny = true;
                        }
                        catch (Exception e)
                        {
                            succcess = false;
                            m_Failures.AddEntry(
                                $"{scenePath}::{AnimationUtility.CalculateTransformPath(sceneObject.transform, sceneObject.transform.root)}",
                                $"{e.Message}\n\n{e.StackTrace}"
                                );
                        }
                    }

                    if (upgradedAny)
                    {
                        EditorSceneManager.SaveScene(scene);
                    }
                }

                if (succcess)
                {
                    m_Successes.AddEntry(scenePath, string.Empty);
                }

                EditorSceneManager.SetActiveScene(EditorSceneManager.NewScene(NewSceneSetup.EmptyScene));
                EditorSceneManager.CloseScene(scene, true);
            }
        }
Beispiel #5
0
 public void UseDefaultAssets() => AssetList.Clear();
Beispiel #6
0
 public static void Clear()
 {
     list.Clear();
 }