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();
        }
        public static VRCP_CollisionLayerSettings GetAndSetShowSetupLayers(bool show)
        {
            VRCP_CollisionLayerSettings settings = LoadLayerSettings();
            bool shouldSave = false;

            if (settings == null)
            {
                settings   = ScriptableObject.CreateInstance <VRCP_CollisionLayerSettings>();
                shouldSave = true;
            }

            settings.showSetupLayers = show;
            EditorUtility.SetDirty(settings);
            if (shouldSave)
            {
                AssetDatabase.CreateAsset(settings, VRCP_CollisionLayerSetup.GetAssetPath(fileName));
            }

            AssetDatabase.SaveAssets();

            return(settings);
        }
 public static VRCP_CollisionLayerSettings LoadLayerSettings()
 {
     return((VRCP_CollisionLayerSettings)AssetDatabase.LoadAssetAtPath(VRCP_CollisionLayerSetup.GetAssetPath(fileName), typeof(VRCP_CollisionLayerSettings)));
 }