private static void ReplaceAsset() { MessengerData temp = messengerData; messengerData = ScriptableObject.CreateInstance <MessengerData>(); messengerData.eventTypes = temp.eventTypes.ConvertAll(e => e.Clone() as MessengerEventTag); }
private static void CreateAsset(string path = null) { messengerData = ScriptableObject.CreateInstance <MessengerData>(); AssetDatabase.CreateAsset(messengerData, path ?? MessengerData.ASSET_PATH); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = messengerData; }
private void OnGUI() { if (messengerDataSerializedObject != null) { messengerDataSerializedObject.Update(); } boxStyle = new GUIStyle(); boxStyle.padding = new RectOffset(5, 5, 5, 5); EditorGUILayout.BeginVertical(boxStyle); EditorGUILayout.BeginHorizontal(); previousData = messengerData; messengerData = EditorGUILayout.ObjectField("Asset", messengerData, typeof(MessengerData), false) as MessengerData; if (GUILayout.Button(createContent, GUILayout.Width(25f))) { var path = EditorUtility.SaveFilePanelInProject("Create new asset", string.Empty, "asset", string.Empty); if (path.Length != 0) { EditorApplication.delayCall += () => OnAssetCreate(path); } } if (previousData != messengerData) { ChangeData(messengerData); previousData = messengerData; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); GUI.enabled = messengerDataSerializedObject != null; scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false); list.DoLayoutList(); GUILayout.EndScrollView(); if (GUILayout.Button(generateFileContent)) { WriteCodeFile(messengerData.name); } EditorGUILayout.EndVertical(); if (messengerDataSerializedObject != null) { messengerDataSerializedObject.ApplyModifiedProperties(); } }
private void ChangeData(MessengerData newData) { messengerDataSerializedObject = newData != null? new SerializedObject(newData) : null; if (messengerDataSerializedObject != null) { list = new ReorderableList(messengerDataSerializedObject, messengerDataSerializedObject.FindProperty("eventTypes"), true, true, true, true); } else { list = new ReorderableList(new System.Collections.Generic.List <string>(), typeof(string), true, true, true, true); } list.drawHeaderCallback += DrawHeader; list.drawElementCallback += DrawElement; list.onAddCallback += AddItem; list.onRemoveCallback += RemoveItem; }
public ActionResult Post([FromBody] MessengerData data) { _logger.LogInformation("Messenger data received"); //System.Console.WriteLine(JsonConvert.SerializeObject(data)); Task.Factory.StartNew(() => { foreach (var entry in data.entry) { foreach (var message in entry.messaging) { // Check current message if text is recognized and sets corresponding payload Messaging currentMessage = mhandler.MessageRecognized(message); if (currentMessage.postback != null) { phandler.handle(message); } else if (!string.IsNullOrWhiteSpace(currentMessage?.message?.quick_reply?.payload)) { //set the quick reply payload as the message payload currentMessage.postback = new Postback { payload = message.message.quick_reply.payload }; phandler.handle(message); } else if (currentMessage?.message?.attachments != null) { try { Attachment locationAtt = currentMessage?.message?.attachments[0]; Coordinates coords = locationAtt.payload?.coordinates; //Console.WriteLine($"Coordinates Received: {coords.lon} {coords.lat}"); string lang = TempUserData.Instance.GetLanguage(currentMessage.sender.id); if (string.IsNullOrWhiteSpace(lang)) { lang = ""; } if (!TempUserData.Instance.WantsToilet(message.sender.id)) { currentMessage.postback = new Postback { payload = $"DEVELOPER_DEFINED_COORDINATES°{coords.lon}:{coords.lat}°{lang}" }; //Console.WriteLine("False " + currentMessage.postback); phandler.handle(message); } else { currentMessage.postback = new Postback { payload = $"GET_TOILET°{coords.lon}:{coords.lat}°{lang}" }; //Console.WriteLine("True " + currentMessage.postback); phandler.handle(message); } TempUserData.Instance.Remove(message.sender.id); //Remove the user from the set } catch (Exception ex) { Console.WriteLine(ex); } } else { mhandler.CheckForKnowText(currentMessage); } } } }); return(Ok()); }
private void OnAssetCreate(string path) { CreateAsset(path); ChangeData(messengerData); previousData = messengerData; }
private static void LoadAsset() { UnityEngine.Object asset = AssetDatabase.LoadAssetAtPath(MessengerData.ASSET_PATH, typeof(MessengerData)); messengerData = (MessengerData)asset; }