Ejemplo n.º 1
0
        void triggerGUI(VRCSDK2.VRC_Trigger triggerComp)
        {
            List <VRCSDK2.VRC_Trigger.TriggerEvent> triggers = triggerComp.Triggers;

            ensureUserSelectsSize(triggers);
            for (int i = 0; i < triggers.Count; i++)
            {
                UserSelects[i] = EditorGUILayout.ToggleLeft(LabelOf(i, triggers[i]), UserSelects[i]);
            }


            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Copy to clipboard")) // "Copy to clipboard as JSON"
            {
                var result = ExportSelected(triggerComp);
                if (OpResultType == MessageType.Info) // means success (not good implementation design)
                {
                    GUIUtility.systemCopyBuffer = result;
                }
            }

            if (GUILayout.Button("Paste from clipboard"))
            {
                ImportToTail(GUIUtility.systemCopyBuffer, triggerComp);
            }
            EditorGUILayout.EndHorizontal();

            if (OpResultType != MessageType.None)
            {
                EditorGUILayout.HelpBox(OpResultMessage, OpResultType, true);
            }
        }
Ejemplo n.º 2
0
        private void ImportToTail(string importString, VRCSDK2.VRC_Trigger triggerComp)
        {
            JsonOperationResult r = JsonTools.ImportPartial_VRC_Trigger_Trigger(importString, triggerComp);

            OpResultType    = r.Type;
            OpResultMessage = r.Message;
        }
Ejemplo n.º 3
0
        private string ExportSelected(VRCSDK2.VRC_Trigger triggerComp)
        {
            JsonOperationResult r = JsonTools.ExportPartial_VRC_Trigger_Trigger(triggerComp, UserSelects);

            OpResultType    = r.Type;
            OpResultMessage = r.Message;
            return(r.Output);
        }
Ejemplo n.º 4
0
        static public JsonOperationResult ImportPartial_VRC_Trigger_Trigger(string importString, VRCSDK2.VRC_Trigger triggerComp)
        {
            return(ImportPartial(importString, triggerComp, (SimpleJSON.JSONNode cmpJsonObj, SimpleJSON.JSONNode expJsonObj) => {
                // Import.
                //   Extract importing JSON object info.
                //   Digest into target object.
                var cmpTriggers = cmpJsonObj["Triggers"];
                var expTriggers = expJsonObj["data"]["Triggers"];
                for (int i = 0; i < expTriggers.Count; i++)
                {
                    cmpTriggers.Add(expTriggers[i]);
                }


                bool advanced = false;
                foreach (var c in cmpTriggers.Values)
                {
                    switch ((VRCSDK2.VRC_EventHandler.VrcBroadcastType)c["BroadcastType"].AsLong)
                    {
                    case VRCSDK2.VRC_EventHandler.VrcBroadcastType.AlwaysUnbuffered:
                    case VRCSDK2.VRC_EventHandler.VrcBroadcastType.OwnerUnbuffered:
                    case VRCSDK2.VRC_EventHandler.VrcBroadcastType.AlwaysBufferOne:
                    case VRCSDK2.VRC_EventHandler.VrcBroadcastType.OwnerBufferOne:
                        break;

                    default:
                        advanced = true;
                        break;
                    }
                }
                if (advanced)
                {
                    cmpJsonObj["UsesAdvancedOptions"] = true;
                }

                return new JsonOperationResult(MessageType.Info,
                                               expTriggers.Count + " entrie(s) added successfully");
            }));
        }