示例#1
0
    private string GetImageDirectory(IconSize iconSize)
    {
        string directory = ModKitHelper.GetToolkitDirectory() + "Icons/PhotoStudioIcons" + iconSize.ToString() + "/";

        DirectoryInfo dirInfo = (new FileInfo(directory)).Directory;

        if (!dirInfo.Exists)
        {
            dirInfo.Create();
        }
        return(directory);
    }
示例#2
0
    public static void Check()
    {
        ModKitHelper.ClearUnityConsole();

        int totalGameObjects;
        List <ShaderUsage> usages = GetShaderUsages(out totalGameObjects);

        foreach (ShaderUsage usage in usages)
        {
            MonoBehaviour.print("Invalid Shader used by " + usage.assetPath + ": " + usage.shaderName + " for material " + usage.materialName);
        }

        MonoBehaviour.print(usages.Count + " out of " + totalGameObjects + " GameObjects use the manual shader.");
    }
示例#3
0
    public static void Remove()
    {
        ModKitHelper.ClearUnityConsole();

        int count = 0;
        int total = 0;

        string[] guids = AssetDatabase.FindAssets("t: GameObject");
        for (int i = 0; i < guids.Length; i++)
        {
            string assetPath = AssetDatabase.GUIDToAssetPath(guids[i]);
            var    importer  = AssetImporter.GetAtPath(assetPath);
            if (importer == null || !(importer is ModelImporter))
            {
                continue;
            }
            ModelImporter modelImporter = importer as ModelImporter;
            List <AssetImporter.SourceAssetIdentifier> remapsToRemove = new List <AssetImporter.SourceAssetIdentifier>();
            foreach (var kvp in modelImporter.GetExternalObjectMap())
            {
                if (kvp.Value is Material)
                {
                    Material mat        = (kvp.Value as Material);
                    string   shaderName = mat.shader.name;
                    if (shaderName.Contains("Manual") && !shaderName.EndsWith("Baked") && !shaderName.Contains("ManualSmall"))
                    {
                        MonoBehaviour.print("Invalid Shader used by " + assetPath + ": " + shaderName + " for material " + mat.name);
                        remapsToRemove.Add(kvp.Key);
                        count++;
                    }
                }
            }
            foreach (var remap in remapsToRemove)
            {
                modelImporter.RemoveRemap(remap);
                AssetDatabase.WriteImportSettingsIfDirty(assetPath);
                AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate);
            }
            total++;
        }

        MonoBehaviour.print(count + " out of " + total + " GameObjects used the manual shader.");
    }