public static void SavePhysicsLayers()
        {
            VRCP_PhysicsLayers layers = ScriptableObject.CreateInstance <VRCP_PhysicsLayers>();

            SerializedObject   serializedObject = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
            SerializedProperty property         = serializedObject.FindProperty("layers");
            List <string>      layerNames       = new List <string>();
            List <int>         layerInd         = new List <int>();

            // Unity and VRChat uses layers 0 - 21, custom layers start at 22.
            for (int layer = 22; layer < 32; ++layer)
            {
                SerializedProperty layerProperty = property.GetArrayElementAtIndex(layer);
                if (layerProperty != null && layerProperty.stringValue.Trim().Length != 0)
                {
                    layerInd.Add(layer);
                    layerNames.Add(layerProperty.stringValue);
                }
            }

            if (layerInd.Count == 0)
            {
                Debug.LogWarning("No custom layers were found.");
                return;
            }

            layers.numLayers       = layerInd.Count;
            layers.layerInd        = layerInd.ToArray();
            layers.layerNames      = layerNames.ToArray();
            layers.layerCollisions = new List <VRCP_BoolArrayContainer>();

            for (int customLayerInd = 0; customLayerInd < layerInd.Count; ++customLayerInd)
            {
                int customLayer = layerInd[customLayerInd];
                layers.layerCollisions.Add(new VRCP_BoolArrayContainer(32));

                for (int layer = 0; layer < 32; ++layer)
                {
                    layers.layerCollisions[customLayerInd].bools[layer] = !Physics.GetIgnoreLayerCollision(customLayer, layer);
                }
            }

            Debug.Log("The following layers were successfully exported:");
            for (int layer = 0; layer < layerInd.Count; ++layer)
            {
                Debug.Log(string.Format("{0} {1}", layerInd[layer], layerNames[layer]));
            }

            AssetDatabase.CreateAsset(layers, VRCP_CollisionLayerSetup.GetAssetPath(fileName));
            AssetDatabase.SaveAssets();
        }
        static void ExportLayers()
        {
            bool continueSetup = EditorUtility.DisplayDialog(
                "Export Current Layers?",
                "This will overwrite the current exported layers with the layers in the current project. Are you sure you want to continue?",
                "Continue",
                "Cancel"
                );

            if (continueSetup)
            {
                VRCP_PhysicsLayers.SavePhysicsLayers();
            }
        }
        public void OnEnable()
        {
            settings = VRCP_CollisionLayerSettings.LoadLayerSettings();
            if (settings == null)
            {
                settings = VRCP_CollisionLayerSettings.GetAndSetShowSetupLayers(true);
            }

            titleContent = new GUIContent("VRC Prefabs Layer Setup V" + version);

            maxSize = new Vector2(350, 200);
            minSize = maxSize;

            physicsLayers = VRCP_PhysicsLayers.LoadPhysicsLayers();
        }
        void ShowMissingLayersFile()
        {
            GUILayout.Label("There was an issue in reading the layer file. Please reimport the prefab package or message the creator.\nFile path: " + GetAssetPath(VRCP_PhysicsLayers.fileName));

            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Try again"))
            {
                physicsLayers = VRCP_PhysicsLayers.LoadPhysicsLayers();
            }
            if (GUILayout.Button("Ignore"))
            {
                VRCP_CollisionLayerSettings.GetAndSetShowSetupLayers(false);
                Close();
            }

            GUILayout.EndHorizontal();
        }