예제 #1
0
        void DrawNotification()
        {
            if (Event.current.type == EventType.DragPerform)
            {
                if (DragAndDrop.objectReferences.Length > 1)
                {
                    return;
                }
            }

            EditorGUILayout.LabelField("Put there you prefab of TPNotification", TPAchievementDesigner.skin.GetStyle("TipLabel"));
            _notification = EditorGUILayout.ObjectField(_notification, typeof(GameObject), false) as GameObject;

            if (_notification == null)
            {
                return;
            }

            if (_notification.GetComponent <TPNotification>() == null)
            {
                _notification.AddComponent <TPNotification>();
            }
            if (notification == null)
            {
                notification = _notification.GetComponent <TPNotification>();
            }

            Space(4);
            EditorGUILayout.LabelField("Notification's Image for Icon", TPAchievementDesigner.skin.GetStyle("TipLabel"));
            notification.iconImage = EditorGUILayout.ObjectField(notification.iconImage, typeof(Image), false) as Image;
            Space(2);
            EditorGUILayout.LabelField("Notification's TextMeshProUGUI for Title", TPAchievementDesigner.skin.GetStyle("TipLabel"));
            notification.titleText = EditorGUILayout.ObjectField(notification.titleText, typeof(TextMeshProUGUI), false) as TextMeshProUGUI;
            Space(2);
            EditorGUILayout.LabelField("Notification's TextMeshProUGUI for Description", TPAchievementDesigner.skin.GetStyle("TipLabel"));
            notification.descriptionText = EditorGUILayout.ObjectField(notification.descriptionText, typeof(TextMeshProUGUI), false) as TextMeshProUGUI;
            Space(2);
            EditorGUILayout.LabelField("Notification's TextMeshProUGUI for Points", TPAchievementDesigner.skin.GetStyle("TipLabel"));
            notification.pointsText = EditorGUILayout.ObjectField(notification.pointsText, typeof(TextMeshProUGUI), false) as TextMeshProUGUI;
            Space(2);
            EditorGUILayout.LabelField("Notification's TextMeshProUGUI for MaxPoints", TPAchievementDesigner.skin.GetStyle("TipLabel"));
            notification.maxPointsText = EditorGUILayout.ObjectField(notification.maxPointsText, typeof(TextMeshProUGUI), false) as TextMeshProUGUI;

            if (GUI.changed)
            {
                // It's werid
                EditorUtility.SetDirty(PrefabUtility.GetPrefabObject(_notification));
            }
        }
 void ChangeNotificationBehavior(TPNotification notification, TPAchievement achievement)
 {
     if (achievement.IsCompleted)
     {
         notification.descriptionText.enabled = true;
         notification.maxPointsText.gameObject.SetActive(false);
         notification.pointsText.gameObject.SetActive(false);
     }
     else
     {
         notification.descriptionText.enabled = false;
         notification.maxPointsText.gameObject.SetActive(true);
         notification.pointsText.gameObject.SetActive(true);
     }
     notification.SetNotification(achievement);
 }