Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Is there any way to disable this warning?

Discussion in 'Editor & General Support' started by jianhua928, Nov 22, 2019.

  1. jianhua928

    jianhua928

    Joined:
    Mar 14, 2019
    Posts:
    13
    When I try to copy the "projectFolder\ProjectSettings\Physics2DSettings.asset"of a project to the Assets folder.
    When used UnityEditor.AssetDatabase:Refresh().
    The following warnings appear:
    "You are trying to import an asset which contains a global game manager. This is not allowed."
    Is there any way to disable this warning?(Invalid attempt to use "#pragma warning disable")
     
  2. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    Why are you trying to copy the Physics2DSettings into Assets?
     
  3. jianhua928

    jianhua928

    Joined:
    Mar 14, 2019
    Posts:
    13
    I need to merge multiple projects, so read all the settings for the project.
    I need to copy Physics2dsettings to assets to load and read using Assetdatabase.
    for example:
    Code (CSharp):
    1. string physics2dAssetPath="..../Physics2DSettings.asset";
    2. SerializedObject serializedObject=new SerializedObject(AssetDatabase.LoadAllAssetsAtPath(physics2dAssetPath));
    3. var it=serializedObject.GetIterator();
    4. while (it.Next(true)){
    5.     string itName=it.name;
    6.     if(itName=="m_Gravity"){
    7.         //read to gravity
    8.     }
    9. }
     
  4. villevli

    villevli

    Joined:
    Jan 19, 2016
    Posts:
    86
    You should be able to just do
    Code (CSharp):
    1. AssetDatabase.LoadAssetAtPath<Object>("ProjectSettings/Physics2DSettings.asset");
    without copying anything
     
  5. jianhua928

    jianhua928

    Joined:
    Mar 14, 2019
    Posts:
    13
    Thank
    It is possible to read only the settings of the current project, but not the external project
     
  6. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    Copy the asset into the ProjectSettings with a temporary name and read that.
     
  7. jianhua928

    jianhua928

    Joined:
    Mar 14, 2019
    Posts:
    13
    It's been tried
     
  8. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    Settings files are YAML. You can read it in as YAML and parse it directly yourself.
     
  9. jianhua928

    jianhua928

    Joined:
    Mar 14, 2019
    Posts:
    13