public override void CustomInspectorGUI() { guiDisabledOrig = GUI.enabled; //DrawDefaultInspector(); serializedObject.Update(); #if UNITY_ANDROID Comment("Android"); #else Comment("iOS"); #endif // token GUILayout.BeginHorizontal(); GUI.enabled = guiDisabledOrig && !lockToken.boolValue && !secretsAreFrozen; if (token.stringValue.Length == 0) { GUI.backgroundColor = Color.red; } EditorGUILayout.PropertyField(token, new GUIContent("Token")); GUI.backgroundColor = originalBackgroundColor; GUI.enabled = guiDisabledOrig; if (!secretsAreFrozen) { bool tokenLockPressed = LockControl(lockToken.boolValue); if (tokenLockPressed) { lockToken.boolValue = !lockToken.boolValue; } GUILayout.Space(8); } GUILayout.EndHorizontal(); // secret GUILayout.BeginHorizontal(); GUI.enabled = guiDisabledOrig && !lockSecret.boolValue && !secretsAreFrozen; if (secret.stringValue.Length == 0) { GUI.backgroundColor = Color.red; } EditorGUILayout.PropertyField(secret, new GUIContent("Secret")); GUI.backgroundColor = originalBackgroundColor; GUI.enabled = guiDisabledOrig; if (!secretsAreFrozen) { bool secretLockPressed = LockControl(lockSecret.boolValue); if (secretLockPressed) { lockSecret.boolValue = !lockSecret.boolValue; } GUILayout.Space(8); } GUILayout.EndHorizontal(); if (!secretsAreFrozen) { if (GUILayout.Button("Import or Create Game")) { PlayHavenWindow.CreateWindow(); } } else { if (GUILayout.Button("Edit Game")) { PlayHavenWindow.CreateWindow(); } } Comment("The token and secret are unique to your account and game. You can be automatically imported for you or obtained from the PlayHaven dashboard."); // doNotDestroyOnLoad EditorGUILayout.PropertyField(doNotDestroyOnLoad, new GUIContent("Keep")); Comment("If \"Keep\" is set, this game object will persist from scene to scene."); // pauseUnity // overlay behavior GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Default Overlay Settings"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); EditorGUILayout.PropertyField(defaultShowsOverlayImmediately, new GUIContent("Show By Default")); // defaultShowsOverlayImmediately EditorGUILayout.PropertyField(maskShowsOverlayImmediately, new GUIContent("Mask")); // maskShowsOverlayImmediately Comment("Defines the default behavior for the content request \"Loading Overlay.\" Setting \"Mask\" completely disables them."); // whenToSendOpen EditorGUILayout.PropertyField(whenToSendOpen, new GUIContent("Notify Open")); Comment("The \"Notify Open\" setting specifies when the manager will notify PlayHaven when your game has launched. If set to manual you will need to call OpenNotification() yourself in your code."); // showContentUnitsInEditor EditorGUILayout.PropertyField(showContentUnitsInEditor, new GUIContent("Content Units in Editor")); Comment("Simulated content units can be displayed in the editor to assist in testing the triggering of placements."); // notifications { // whenToGetNotifications EditorGUILayout.PropertyField(whenToGetNotifications, new GUIContent("Fetch Badges")); if (whenToGetNotifications.enumValueIndex == (int)PlayHavenManager.WhenToGetNotifications.Poll) { //GUILayout.Space(4); GUILayout.Label("Fetch Polling Attributes:"); EditorGUI.indentLevel = 1; // notificationPollDelay GUILayout.BeginHorizontal(); //GUILayout.Space(16); EditorGUILayout.PropertyField(notificationPollDelay, new GUIContent("Delay (seconds)")); if (notificationPollDelay.floatValue < 0) { notificationPollDelay.floatValue = 0; } GUILayout.EndHorizontal(); // notificationPollRate GUILayout.BeginHorizontal(); //GUILayout.Space(16); EditorGUILayout.PropertyField(notificationPollRate, new GUIContent("Rate (seconds)")); if (notificationPollRate.floatValue < 1) { notificationPollRate.floatValue = 1; } GUILayout.EndHorizontal(); EditorGUI.indentLevel = 0; } Comment("Specify if and how often to fetch badge notifications. When a badge value is fetched, its value will be available from the Fetch property of the manager."); } // auto-cancelling of stale requests { EditorGUILayout.PropertyField(cancelAllOnLevelLoad, new GUIContent("Cancel On Load")); Comment("This setting automatically cancels any pending requests when a new level is loaded."); } // automatic content request suppression { performLaunchSupression = EditorGUILayout.Toggle("Launch Suppression", performLaunchSupression); if (performLaunchSupression) { // count if (suppressContentRequestsForLaunches.intValue < 1) { suppressContentRequestsForLaunches.intValue = 1; } EditorGUILayout.IntSlider(suppressContentRequestsForLaunches, 1, 10, new GUIContent("Number of Launches")); // exceptions SerializedProperty suppressedPlacement; SerializedProperty suppressionException; int numSupressions = suppressedPlacements.arraySize; int numExceptions = suppressionExceptions.arraySize; GUILayout.Space(4); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (numExceptions == 0 && GUILayout.Button("Add Suppressed Placement")) { suppressedPlacements.arraySize++; suppressedPlacement = serializedObject.FindProperty(System.String.Format("suppressedPlacements.Array.data[{0}]", suppressedPlacements.arraySize - 1)); suppressedPlacement.stringValue = string.Empty; } if (numSupressions == 0 && GUILayout.Button("Add Exempted Placement")) { suppressionExceptions.arraySize++; suppressionException = serializedObject.FindProperty(System.String.Format("suppressionExceptions.Array.data[{0}]", suppressionExceptions.arraySize - 1)); suppressionException.stringValue = string.Empty; } GUILayout.EndHorizontal(); if (numSupressions > 0) { int suppressionToDelete = -1; GUILayout.Label("Placement to Suppress", EditorStyles.boldLabel); for (int i = 0; i < numSupressions; i++) { suppressedPlacement = serializedObject.FindProperty(System.String.Format("suppressedPlacements.Array.data[{0}]", i)); GUILayout.BeginHorizontal(); if (suppressedPlacement.stringValue.Length > 0 && !placementTagsList.Contains(suppressedPlacement.stringValue)) { EditorGUILayout.PropertyField(suppressedPlacement, new GUIContent("Placement #" + (i + 1))); } else { int selectedPlacement = -1; for (int j = 0; j < placementTagsList.Count; j++) { if (placementTagsList[j] == suppressedPlacement.stringValue) { selectedPlacement = j; break; } } int newSelectedPlacement = EditorGUILayout.Popup("Placement #" + (i + 1), selectedPlacement, placementTagsList.ToArray()); if (newSelectedPlacement != selectedPlacement) { suppressedPlacement.stringValue = placementTagsList[newSelectedPlacement]; } } if (GUILayout.Button("-", GUILayout.Width(18), GUILayout.Height(14))) { if (EditorUtility.DisplayDialog("Confirm Deletion", "Are you sure you want to remove this placement suppression?", "Yes", "No")) { suppressionToDelete = i; } } GUILayout.EndHorizontal(); } if (suppressionToDelete >= 0) { for (int i = suppressionToDelete; i < numSupressions - 1; i++) { suppressedPlacements.MoveArrayElement(i + 1, i); } suppressedPlacements.arraySize--; } } if (numExceptions > 0) { int exemptionToDelete = -1; GUILayout.Label("Placement to Exempt", EditorStyles.boldLabel); for (int i = 0; i < numExceptions; i++) { suppressionException = serializedObject.FindProperty(System.String.Format("suppressionExceptions.Array.data[{0}]", i)); GUILayout.BeginHorizontal(); if (suppressionException.stringValue.Length > 0 && !placementTagsList.Contains(suppressionException.stringValue)) { EditorGUILayout.PropertyField(suppressionException, new GUIContent("Placement #" + (i + 1))); } else { int selectedPlacement = -1; for (int j = 0; j < placementTagsList.Count; j++) { if (placementTagsList[j] == suppressionException.stringValue) { selectedPlacement = j; break; } } int newSelectedPlacement = EditorGUILayout.Popup("Placement #" + (i + 1), selectedPlacement, placementTagsList.ToArray()); if (newSelectedPlacement != selectedPlacement) { suppressionException.stringValue = placementTagsList[newSelectedPlacement]; } } if (GUILayout.Button("-", GUILayout.Width(18), GUILayout.Height(14))) { if (EditorUtility.DisplayDialog("Confirm Deletion", "Are you sure you want to remove this placement suppression excemption?", "Yes", "No")) { exemptionToDelete = i; } } GUILayout.EndHorizontal(); } if (exemptionToDelete >= 0) { for (int i = exemptionToDelete; i < numExceptions - 1; i++) { suppressionExceptions.MoveArrayElement(i + 1, i); } suppressionExceptions.arraySize--; } } } else { suppressContentRequestsForLaunches.intValue = 0; } Comment("Launch Suppression allows the automatic suppression of content requests until the game has been launched a programmable number of times."); } serializedObject.ApplyModifiedProperties(); }
public override void CustomInspectorGUI() { guiDisabledOrig = GUI.enabled; //DrawDefaultInspector(); requester.Update(); // placement if (placement.stringValue.Length == 0) { GUI.backgroundColor = Color.red; } if (placement.stringValue.Length > 0 && !placementTagsList.Contains(placement.stringValue)) { EditorGUILayout.PropertyField(placement, new GUIContent("Placement")); } else { selectedPlacement = EditorGUILayout.Popup("Placement", selectedPlacement, placementTagsList.ToArray()); placement.stringValue = (selectedPlacement >= 0) ? placementTagsList[selectedPlacement] : string.Empty; } GUI.backgroundColor = originalBackgroundColor; EditorGUILayout.BeginHorizontal(); if (placement.stringValue.Length > 0 && placementTagsList.Contains(placement.stringValue)) { if (GUILayout.Button("Edit...")) { Placement placementObj = null; #if UNITY_ANDROID placementObj = settings.GetPlacementByTag(placement.stringValue, Game.OperatingSystem.android); #else placementObj = settings.GetPlacementByTag(placement.stringValue, Game.OperatingSystem.ios); #endif if (placementObj != null) { PlayHavenWindow.CreateWindow(PlayHavenWindow.TOOLBAR_PLACEMENTS); PlayHavenWindow w = PlayHavenWindow.Get(); w.SetPlacementToEdit(placementObj); } } } if (settings.HasGameAndroid || settings.HasGameIOS) { if (GUILayout.Button("New...")) { PlayHavenWindow.CreateWindow(PlayHavenWindow.TOOLBAR_PLACEMENTS); } } if (placement.stringValue.Length > 0 && placementTagsList.Contains(placement.stringValue)) { if (GUILayout.Button("Refresh")) { RefreshPlacementList(); } } EditorGUILayout.EndHorizontal(); Comment("Placements define the locations in your game where content may appear to your players."); // whenToRequest EditorGUILayout.PropertyField(whenToRequest); if (whenToRequest.enumValueIndex != 3) // !OnDisable { delayRequest = EditorGUILayout.Toggle("Delay Request", delayRequest); GUI.enabled = guiDisabledOrig && delayRequest; GUILayout.BeginHorizontal(); requestDelay.floatValue = EditorGUILayout.Slider("Seconds", requestDelay.floatValue, DELAY_MIN, DELAY_MAX); GUI.enabled = guiDisabledOrig; GUILayout.EndHorizontal(); if (!delayRequest) { requestDelay.floatValue = 0f; } } Comment("Specify when to make the request. If set to manual, you will need to call the Request() method on this component yourself in your code."); // prefetching EditorGUILayout.PropertyField(prefetch); EditorGUILayout.PropertyField(connectionForPrefetch); EditorGUILayout.PropertyField(refetchWhenUsed); Comment("Automatic pre-fetching characteristics."); // pauseGameWhenDisplayed /* * EditorGUILayout.PropertyField(pauseGameWhenDisplayed, new GUIContent("Pause When Displayed")); * Comment("If set, the timescale will be set to 0 when the content unit is displayed and returned to the previous timescale when dismissed."); */ // showsOverlayImmediately EditorGUILayout.PropertyField(showsOverlayImmediately, new GUIContent("Loading Overlay")); Comment("If \"Loading Overlay\" is set, an overlay will be shown so that the user cannot interact with the game while the content is being fetched."); EditorGUILayout.PropertyField(rewardMayBeDelivered, new GUIContent("Rewardable")); { // rewardMessageType if (rewardMayBeDelivered.boolValue) { //EditorGUI.indentLevel = 1; EditorGUILayout.PropertyField(rewardMessageType, new GUIContent("Message Type")); // default test reward EditorGUILayout.PropertyField(useDefaultTestReward, new GUIContent("Test Def. Reward")); if (useDefaultTestReward.boolValue) { EditorGUI.indentLevel = 0; GUILayout.BeginHorizontal(); GUILayout.Space(6); GUILayout.Label("Test Default Reward"); GUILayout.EndHorizontal(); EditorGUI.indentLevel = 1; EditorGUILayout.PropertyField(defaultTestRewardName, new GUIContent("Name")); EditorGUILayout.PropertyField(defaultTestRewardQuantity, new GUIContent("Quantity")); EditorGUI.indentLevel = 0; GUI.enabled = guiDisabledOrig; //GUILayout.Space(8); } // manual test capability if (Application.isPlaying) { EditorGUI.indentLevel = 0; GUILayout.BeginHorizontal(); GUILayout.Space(6); GUILayout.Label("Test Reward Now"); GUILayout.EndHorizontal(); EditorGUI.indentLevel = 1; if (testRewardKey.Length > 0 && !rewardTagsList.Contains(testRewardKey)) { testRewardKey = EditorGUILayout.TextField("Name", testRewardKey); } else { selectedReward = EditorGUILayout.Popup("Name", selectedReward, rewardTagsList.ToArray()); testRewardKey = (selectedReward > -1) ? rewardTagsList[selectedReward] : string.Empty; } testRewardQuantity = EditorGUILayout.IntField("Quantity", testRewardQuantity); EditorGUI.indentLevel = 0; GUI.enabled = guiDisabledOrig && testRewardKey.Length > 0; if (GUILayout.Button("Give Reward")) { PlayHaven.Reward reward = new PlayHaven.Reward(); reward.name = testRewardKey; reward.quantity = testRewardQuantity; ((PlayHavenContentRequester)target).HandlePlayHavenManagerOnRewardGiven(0, reward); } GUI.enabled = guiDisabledOrig; //GUILayout.Space(8); } EditorGUI.indentLevel = 0; } } Comment("If \"Rewardable\" is set, this game object is automatically wired to receive reward notifications when this placement is reported. If a reward is delivered, a message OnPlayHavenRewardGiven(PlayHaven.Reward) will be broadcast to this game object."); // usage EditorGUILayout.PropertyField(limitedUse, new GUIContent("Limited Use")); GUI.enabled = guiDisabledOrig && limitedUse.boolValue; EditorGUILayout.PropertyField(maxUses, new GUIContent("Max Uses")); EditorGUILayout.PropertyField(exhaustAction, new GUIContent("Exhaust Action")); GUI.enabled = guiDisabledOrig; if (maxUses.intValue < 1) { maxUses.intValue = 1; } Comment("You can limit how many times a content requester can be used with the above settings."); requester.ApplyModifiedProperties(); if (Application.isPlaying) { PlayHavenContentRequester playHavenContentRequester = (PlayHavenContentRequester)target; if (playHavenContentRequester != null) { GUILayout.Space(8); if (GUILayout.Button("Test this Request")) { playHavenContentRequester.Request(); } } } }