예제 #1
0
        private void ResetEditor(SerializedProperty property, JuicyFeedbackBase feedback)
        {
            int referenceCount = feedback.referenceCount;

            if (PrefabUtility.IsPartOfAnyPrefab(property.objectReferenceValue))
            {
                PrefabUtility.RevertObjectOverride(feedback, InteractionMode.UserAction);
                feedback.referenceCount = referenceCount;
                return;
            }

            // Create a temporary feedback and copy the values
            JuicyFeedbackBase tmpFeedback = AddFeedback(feedback.GetType());
            int index = feedbackListProp.arraySize - 1;

            tmpFeedback.referenceCount = referenceCount;

            SerializedProperty tmp = feedbackListProp
                                     .GetArrayElementAtIndex(index);

            JuicyEditorUtils.CopyFeedback(tmp, tmpFeedback);
            JuicyEditorUtils.PasteFeedback(property, feedback);
            FeedbackCopyHelper.ClearCache();

            RemoveFeedback(tmp, tmpFeedback, index);

            serializedObject.ApplyModifiedProperties();
        }
예제 #2
0
        public static void PasteFeedback(SerializedProperty property,
                                         JuicyFeedbackBase feedback)
        {
            SerializedObject serialized = new SerializedObject(feedback);

            FeedbackCopyHelper.Paste(serialized);
            serialized.ApplyModifiedProperties();
        }
예제 #3
0
        private void PasteAsNew()
        {
            JuicyFeedbackBase newFeedback = AddFeedback(FeedbackCopyHelper.Type);

            SerializedObject obj = new SerializedObject(newFeedback);

            obj.Update();
            FeedbackCopyHelper.Paste(obj);
            obj.ApplyModifiedProperties();

            serializedObject.ApplyModifiedProperties();
        }
예제 #4
0
        private void ShowElementContextMenu(int index)
        {
            SerializedProperty property = feedbackListProp.GetArrayElementAtIndex(index);
            JuicyFeedbackBase  feedback = property.objectReferenceValue as JuicyFeedbackBase;

            var itemMenu = new GenericMenu();

            itemMenu.AddItem(JuicyEditorUtils.GetContent("Remove|Remove feedback from List"),
                             false, () => Remove(property, feedback, index));
            itemMenu.AddItem(JuicyEditorUtils.GetContent("Reset|Resets the feedback to default"),
                             false, () => ResetEditor(property, feedback));
            itemMenu.AddSeparator(string.Empty);
            itemMenu.AddItem(JuicyEditorUtils.GetContent("Copy|Copy feedback values"),
                             false, () =>
            {
                FeedbackCopyHelper.CopyReference(feedback);
                JuicyEditorUtils.CopyFeedback(property, feedback);
            });

            if (FeedbackCopyHelper.HasCopy)
            {
                itemMenu.AddItem(JuicyEditorUtils.GetContent("Paste|Paste feedback values"),
                                 false, () =>
                                 JuicyEditorUtils.PasteFeedback(property, feedback));
                itemMenu.AddItem(JuicyEditorUtils.GetContent("Paste as new|Paste copied feedback values as a new feedback"),
                                 false, PasteAsNew);

                itemMenu.AddItem(JuicyEditorUtils.GetContent("Paste Reference|Paste feedback reference"),
                                 false, () =>
                {
                    FeedbackCopyHelper.PasteReference(juicyFeedbackList.feedbackList);
                });
            }
            else
            {
                itemMenu.AddDisabledItem(JuicyEditorUtils.GetContent("Paste"));
            }

            Rect menuRect = new Rect(Event.current.mousePosition, Vector2.zero);

            menuRect.y -= 10;

            itemMenu.DropDown(menuRect);
        }
예제 #5
0
        private void Remove(SerializedProperty property,
                            JuicyFeedbackBase feedback, int index)
        {
            /*if (EditorUtility.DisplayDialog(
             *  $"Remove {label} Feedback",
             *  $"Do you really want to remove the {label} Feedback?",
             *  "Yes", "No")) {
             * }*/

            if (feedback.referenceCount == 0)
            {
                RemoveFeedback(property, feedback, index);
            }
            else
            {
                FeedbackCopyHelper.RemoveCopyReference(feedback,
                                                       juicyFeedbackList.feedbackList);
            }
        }
예제 #6
0
 public static void CopyFeedback(SerializedProperty property,
                                 JuicyFeedbackBase feedback)
 {
     FeedbackCopyHelper.Copy(new SerializedObject(feedback));
 }