public static void ValidateState(UnitySocialSettings settings) { bool isValid = false; if (settings != null && settings.IsValid) { isValid = true; } foreach (BuildTargetGroup target in System.Enum.GetValues(typeof(BuildTargetGroup))) { if (target == kBuildTargetGroup_iOS) { UnitySocialPostprocessor.SetScriptingDefineSymbolForTarget(kBuildTargetGroup_iOS, "UNITY_SOCIAL", isValid ? settings.iosSupportEnabled : false); } else if (target == BuildTargetGroup.Android) { UnitySocialPostprocessor.SetScriptingDefineSymbolForTarget(BuildTargetGroup.Android, "UNITY_SOCIAL", isValid ? settings.androidSupportEnabled : false); } } }
public override void OnInspectorGUI() { try { // Might be null when this gui is open and this file is being reimported if (target == null) { Selection.activeObject = null; return; } currentSettings = (UnitySocialSettings)target; if (currentSettings != null) { bool settingsValid = currentSettings.IsValid; EditorGUILayout.HelpBox("1) Enter your game credentials", MessageType.None); if (!currentSettings.IsValid) { EditorGUILayout.HelpBox("Invalid or missing game credentials, Unity Social disabled.", MessageType.Error); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(labelClientId, GUILayout.Width(108), GUILayout.Height(18)); currentSettings.clientId = TrimmedText(EditorGUILayout.TextField(currentSettings.clientId)); EditorGUILayout.EndHorizontal(); EditorGUILayout.HelpBox("2) Enable Unity Social on these platforms", MessageType.None); EditorGUILayout.BeginVertical(); bool validityChanged = currentSettings.IsValid != settingsValid; bool selectedPlatformsChanged = false; iosSupportEnabled = EditorGUILayout.Toggle(labelSupport_iOS, currentSettings.iosSupportEnabled); androidSupportEnabled = EditorGUILayout.Toggle(labelSupport_Android, currentSettings.androidSupportEnabled); if (iosSupportEnabled != currentSettings.iosSupportEnabled) { selectedPlatformsChanged = true; currentSettings.iosSupportEnabled = iosSupportEnabled; if (iosSupportEnabled) { iOSTargetOSVersion v = PlayerSettings.iOS.targetOSVersion; if (v == iOSTargetOSVersion.iOS_4_0 || v == iOSTargetOSVersion.iOS_4_1 || v == iOSTargetOSVersion.iOS_4_2 || v == iOSTargetOSVersion.iOS_4_3 || v == iOSTargetOSVersion.iOS_5_0 || v == iOSTargetOSVersion.iOS_5_1 || v == iOSTargetOSVersion.iOS_6_0 || v == iOSTargetOSVersion.Unknown) { PlayerSettings.iOS.targetOSVersion = iOSTargetOSVersion.iOS_7_0; Debug.Log("Unity Social requires minimum iOS 7.0. Target OS version updated to 7.0"); } } EditorUtility.SetDirty(currentSettings); } else if (androidSupportEnabled != currentSettings.androidSupportEnabled) { EnableAndroidSupport(androidSupportEnabled); selectedPlatformsChanged = true; currentSettings.androidSupportEnabled = androidSupportEnabled; if (androidSupportEnabled) { AndroidSdkVersions sdkVer = PlayerSettings.Android.minSdkVersion; if (sdkVer < AndroidSdkVersions.AndroidApiLevel16) { PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel16; Debug.Log("Unity Social requires minimum Android API level 16. API minSdkVersion updated to 16."); } } EditorUtility.SetDirty(currentSettings); } if (validityChanged || selectedPlatformsChanged) { UnitySocialPostprocessor.ValidateState(currentSettings); } EditorGUILayout.EndVertical(); } } catch (Exception e) { if (e != null) { } } }