(IN-47549) "UnityException: Could not find the requested Platform Texture Settings."

In case that anyone is stumbling across this error:

UnityException: Could not find the requested Platform Texture Settings. This is incorrect, did initialization fail?

It was marked as fixed already, but it isn’t in 2023.2.0a20 and 2023.2.0a22.
I’ve reported it again with detailed reproduction steps as IN-47549.

For me this started happening after installing the dedicated server build target as module. It is happening when “buildTarget: Server” is missing under “platformSettings:” in the metadata file of the texture. For some reason Unity currently isn’t generating the metadata file correctly, resulting in the error above.

A manual workaround for now is to add the missing buildTarget manually to the metadata file. Simply copy the whole block for “buildTarget: DefaultTexturePlatform” and rename the copy to “buildTarget: Server”.
I’m not sure if this is also happening with other build targets on other operating systems or whatever. If you are stuck with this error on another platform, this post should give you an idea what to look for at least.

Here is a screenshot of a modified working metadata file and a bugged default one generated by Unity:

2 Likes

The same problem is happening here too, I’m using the dedicated server module too.
Unity version 2023.1.5f1

Hi. I have same issue too (Unity 2023.1.6f1). Can you share public issue tracker link?

Sure: UUM-44737

1 Like

What i want to know is this. Surely unity must do a test on import for all its types so how does this kinda error find its way into a version?

Work around would be this

  1. Export out the exr file using unitypackage in 2021.3.30f1 (this version works)
    (Note you cant drag the file between the unity versions as it dont work)
  2. Import into version that dont work (in my case 2023.1.10f1)
  3. Voila! its imported (still shows the error if you click on it but you can successfully drag it onto the HDRI Sky property in the Volume profile.

If you have an hdr file and need it in exr format you could use https://convertio.co/ which will do the conversion for free!

Breaks for me as well. Assets other’s have imported on my project are just fine. Attempting to add new assets with Dedicated Server install however throws errors immediately.

Yea it keeps doing that to me also, Instead it spams my consle

Encountering this in 2023.1.15f1

Encountering this in 6000.0.0f1 and 6000.0.1f1

There are different issues that cause this exception, Unity has fixed a few of them but it seems new ones appeared or others haven’t been reproduced yet. If you encounter this error, try to recreate in a new project and report a bug.

I just got this on Unity 6000.0.5 and it was caused by a default preset for textures. The preset originally came from Unity 2022.2 and used “iPhone” as a platform name. It seems Unity has renamed this platform to “iOS” in the meantime but the preset caused new textures to have an “iPhone” instead of an “iOS” platform settings entry, which ultimately caused this issue.

It’s easy to check if you’re affected with the same issue: Inspecting the broken preset causes the same exception to be logged in the console repeatedly. Either edit the preset file and replace “iPhone” with “iOS” or recreate the preset. Note that it only happens if the preset is setup as the default, not when applying it manually. To fix the textures, you can either apply the fixed preset or replace “iPhone” with “iOS” in the textures’ meta files.

Reported and reproduced as UUM-73858.

3 Likes

Thank you Adrian! your post helped me to find a solution for this, it was driving me crazy!
Another guy posted a script to rewrite the metadata so I made a script making a simple modification to change the “iPhone” to “iOS”.
To use it you have to place it in a “Editor” folder and import the “Editor Coroutines” package from the package manager, then you right clic on the folder with the images and “Reimport”.

using UnityEngine;
using UnityEditor;
using Unity.EditorCoroutines.Editor;

using System.Collections;
using System.IO;
using System.Text;


public class FixTexturePlatformSettings: AssetPostprocessor
{
 
    void OnPostprocessTexture(Texture2D texture)
    {
        EditorCoroutineUtility.StartCoroutine(Fix($"{assetPath}.meta"), this);
    }
   
    private IEnumerator Fix(string metafile)
    {
        // Wait for .meta to be created
        while (!File.ReadAllText(metafile).Contains("platformSettings:"))
            yield return null;

        // Read .meta file
        string original = File.ReadAllText(metafile);
        StringBuilder meta = new(original);

        if (meta.ToString().Contains("iPhone"))
        {
            meta.Replace("iPhone", "iOS");
            Debug.Log("Replaced iPhone to iOS");
        }

        // Save .meta file
        if (meta.ToString() != original)
        {
            File.WriteAllText(metafile, meta.ToString());
            AssetDatabase.Refresh();
        }
    }
}

Encountering this in 6000.0.23f1 (LTS)

1 Like

The original issue has been fixed long ago. Have you checked if it’s the newer issue I’ve reported and whose fix is still in progress?

Otherwise, try to reproduce it in a new project and report a bug, as this would be a new/different issue to what has been discussed in this thread.

1 Like

Oh, I just found out the reason why. My project was just switched from 2022.2.50f1 and I was using TextureImporter Presets. I deleted that preset and recreated it on Unity 6000.0.23f1 and the error is gone!

This issue got finally resolved at least in my case after comments about presets. I had some presets, most likely imported by some asset, that I didn’t know would affect this. Import works after deleting the presets. Thanks!