コード例 #1
0
        public static PlayFabSharedSettings LoadFromResources()
        {
            var settingsList = Resources.LoadAll <PlayFabSharedSettings>("PlayFabSDK");
            PlayFabSharedSettings settings = null;

            if (settingsList.Length == 1)
            {
                settings = settingsList[0];
            }
            if (settings != null)
            {
                return(settings);
            }
#if UNITY_EDITOR
            settings = CreateInstance <PlayFabSharedSettings>();
            var path = Path.Combine("Assets", "Resources", "PlayFabSDK");
            Directory.CreateDirectory(path);

            UnityEditor.AssetDatabase.CreateAsset(settings, Path.Combine(path, "PlayFabSharedSettings.asset"));
            UnityEditor.AssetDatabase.SaveAssets();
            Debug.LogWarning("Created missing PlayFabEditorPrefsSO file");
            return(settings);
#else
            throw new System.Exception("The number of PlayFabSharedSettings objects should be 1: " + settingsList.Length);
#endif
        }
コード例 #2
0
        public static void MakePlayFabSharedSettings()
        {
            PlayFabSharedSettings asset = ScriptableObject.CreateInstance <PlayFabSharedSettings>();

            AssetDatabase.CreateAsset(asset, "Assets/PlayFabSDK/PlayFabSharedSettings.asset"); // TODO: Path should not be hard coded
            AssetDatabase.SaveAssets();

            EditorUtility.FocusProjectWindow();

            Selection.activeObject = asset;
        }