예제 #1
0
    void Awake()
    {
        staticRef = this;

                #if auth
        SerializedObject serializedTarget = new SerializedObject(target);

        lastFacebookState = serializedTarget.FindProperty("enableFacebookLoginAPI").boolValue;
        lastTwitterState  = serializedTarget.FindProperty("enableTwitterLoginAPI").boolValue;
        lastGoogleState   = serializedTarget.FindProperty("enableGooglePlayGamesAPI").boolValue;
                #endif
    }
    public override void OnInspectorGUI()
    {
        SerializedObject serializedTarget = new SerializedObject(target);

                #if UNITY_4
        EditorGUILayout.HelpBox("These plugins do not officially support Unity 4! Make sure you know what you're doing as the plugins and scripts are untested in Unity 4!", MessageType.Warning);
                #endif

        bool adMobEnabled        = serializedTarget.FindProperty("useAdMob").boolValue;
        bool iasEnabled          = serializedTarget.FindProperty("useIAS").boolValue;
        bool analyticsEnabled    = serializedTarget.FindProperty("useFirebaseAnalytics").boolValue;
        bool remoteConfigEnabled = serializedTarget.FindProperty("useFirebaseRemoteConfig").boolValue;
        bool authEnabled         = serializedTarget.FindProperty("useFirebaseAuth").boolValue;
        bool databaseEnabled     = serializedTarget.FindProperty("useFirebaseDatabase").boolValue;
        bool invitesEnabled      = serializedTarget.FindProperty("useFirebaseInvites").boolValue;
        bool messagingEnabled    = serializedTarget.FindProperty("useFirebaseMessaging").boolValue;
        bool storageEnabled      = serializedTarget.FindProperty("useFirebaseStorage").boolValue;

        if (!adMobEnabled)
        {
            EditorGUILayout.HelpBox("The AdMob plugin is disabled! Unless told otherwise your project should always contain the admob plugin!", MessageType.Warning);
        }
        if (!iasEnabled)
        {
            EditorGUILayout.HelpBox("The IAS plugin is disabled! Unless told otherwise your project should always contain this plugin!", MessageType.Warning);
        }
        if (!analyticsEnabled)
        {
            EditorGUILayout.HelpBox("The Analytics plugin is disabled! Unless told otherwise your project should always contain this plugin!", MessageType.Warning);
        }
        if (!remoteConfigEnabled)
        {
            EditorGUILayout.HelpBox("The Remote Config plugin is disabled! We use this plugin to control some backend settings in your app! Unless told otherwise this plugin should be enabled!", MessageType.Warning);
        }

        if (lastAdMobState != adMobEnabled)
        {
            ModifyScriptingDefineSymbol(ScriptingDefineSymbols.admob, adMobEnabled, true);
            lastAdMobState = adMobEnabled;
        }

        if (lastIasState != iasEnabled)
        {
            ModifyScriptingDefineSymbol(ScriptingDefineSymbols.ias, iasEnabled, true);
            lastIasState = iasEnabled;
        }

        if (lastAnalyticsState != analyticsEnabled)
        {
            if (!analyticsEnabled)
            {
                // We need to first disable crashlytics properly so it removes crashlytics references from the Fabric manifest
                                #if analytics
                Fabric.Internal.Crashlytics.Editor.CrashlyticsSetup.DisableCrashlytics();
                                #endif
            }

            ModifyScriptingDefineSymbol(ScriptingDefineSymbols.analytics, analyticsEnabled, true);
            lastAnalyticsState = analyticsEnabled;

            if (analyticsEnabled)
            {
                // Re-add crashlytics to the Fabric manifest
                                #if analytics
                Fabric.Internal.Crashlytics.Editor.CrashlyticsSetup.EnableCrashlytics(true);
                                #endif
            }
        }

        if (lastRemoteConfigState != remoteConfigEnabled)
        {
            ModifyScriptingDefineSymbol(ScriptingDefineSymbols.remote_config, remoteConfigEnabled, true);
            lastRemoteConfigState = remoteConfigEnabled;
        }

        if (lastAuthState != authEnabled)
        {
            if (!authEnabled)
            {
                // Force remove the facebook define symbol if auth is disabled
                ModifyScriptingDefineSymbol(ScriptingDefineSymbols.facebook, false);

                // Force remove the twitter define symbol too
                ModifyScriptingDefineSymbol(ScriptingDefineSymbols.twitter, false);

                // Force remove the google define symbol too
                ModifyScriptingDefineSymbol(ScriptingDefineSymbols.google, false);
            }
            else
            {
                // This forces the facebook and twitter states to be recalculate when auth is enabled again
                AuthEditor.RecalculateScriptingDefines();
            }

            // We need to disable auth after facebook and twitter or we'll have issues
            ModifyScriptingDefineSymbol(ScriptingDefineSymbols.auth, authEnabled, true);
            lastAuthState = authEnabled;
        }

        if (lastDatabaseState != databaseEnabled)
        {
            ModifyScriptingDefineSymbol(ScriptingDefineSymbols.database, databaseEnabled, true);
            lastDatabaseState = databaseEnabled;
        }

        if (lastInvitesState != invitesEnabled)
        {
            ModifyScriptingDefineSymbol(ScriptingDefineSymbols.invites, invitesEnabled, true);
            lastInvitesState = invitesEnabled;
        }

        if (lastMessagingState != messagingEnabled)
        {
            ModifyScriptingDefineSymbol(ScriptingDefineSymbols.messaging, messagingEnabled, true);
            lastMessagingState = messagingEnabled;
        }

        if (lastStorageState != storageEnabled)
        {
            ModifyScriptingDefineSymbol(ScriptingDefineSymbols.storage, storageEnabled, true);
            lastStorageState = storageEnabled;
        }

        if (GUILayout.Button("Force hide progress bar"))
        {
            OnScriptsReloaded();
        }

        if (GUILayout.Button("Recalculate Scripting Defines (Not usually needed)"))
        {
            ClearScriptingDefineSymbols();

            lastAdMobState = lastAnalyticsState = lastAuthState = lastDatabaseState = lastIasState = lastInvitesState = lastMessagingState = lastRemoteConfigState = lastStorageState = false;
            AuthEditor.RecalculateScriptingDefines();
            ModifyPlugins("firebase_global", true, false);
            Debug.Log("Scripting defines recalculated! Note: Any custom set defines need to be set again!");
        }

        if (GUILayout.Button("Update plugin file list (Reads plugins from PluginImportData.json)"))
        {
            UpdatePluginList(true);
        }

        DrawDefaultInspector();
    }