void OnGUI() { UpdateToStartPos(); GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Cloud Kit", style); StartY+= YLableStep; if(GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Create Record")) { CK_RecordID recordId = new CK_RecordID("1"); CK_Record record = new CK_Record(recordId, "Post"); record.SetObject("PostText", "Sample point of interest"); record.SetObject("PostTitle", "My favorite point of interest"); CK_Database database = ISN_CloudKit.Instance.PublicDB; database.SaveRecrod(record); database.ActionRecordSaved += Database_ActionRecordSaved; } StartX += XButtonStep; if(GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Delete Record")) { CK_RecordID recordId = new CK_RecordID("1"); CK_Database database = ISN_CloudKit.Instance.PublicDB; database.DeleteRecordWithID(recordId); database.ActionRecordDeleted += Database_ActionRecordDeleted; } StartX += XButtonStep; if(GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Fetch Record")) { CK_RecordID recordId = new CK_RecordID("1"); CK_Database database = ISN_CloudKit.Instance.PublicDB; database.FetchRecordWithID(recordId); database.ActionRecordFetchComplete += Database_ActionRecordFetchComplete; } }
void OnGUI() { UpdateToStartPos(); GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Cloud Kit", style); StartY += YLableStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Create Record")) { CK_RecordID recordId = new CK_RecordID("1"); CK_Record record = new CK_Record(recordId, "Post"); record.SetObject("PostText", "Sample point of interest"); record.SetObject("PostTitle", "My favorite point of interest"); CK_Database database = ISN_CloudKit.Instance.PublicDB; database.SaveRecrod(record); database.ActionRecordSaved += Database_ActionRecordSaved; } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Delete Record")) { CK_RecordID recordId = new CK_RecordID("1"); CK_Database database = ISN_CloudKit.Instance.PublicDB; database.DeleteRecordWithID(recordId); database.ActionRecordDeleted += Database_ActionRecordDeleted; } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Fetch Record")) { CK_RecordID recordId = new CK_RecordID("1"); CK_Database database = ISN_CloudKit.Instance.PublicDB; database.FetchRecordWithID(recordId); database.ActionRecordFetchComplete += Database_ActionRecordFetchComplete; } }
void Database_ActionRecordFetchForUpdateComplete(CK_RecordResult res) { res.Database.ActionRecordFetchComplete -= Database_ActionRecordFetchForUpdateComplete; if (res.IsSucceeded) { ISN_Logger.Log("Database_ActionRecordFetchComplete:"); ISN_Logger.Log("Post Title: " + res.Record.GetObject("PostTitle")); ISN_Logger.Log("Updatting Title: "); CK_Record record = res.Record; record.SetObject("PostTitle", "My favorite point of interest - updated"); ISN_CloudKit.Instance.PrivateDB.SaveRecrod(record); ISN_CloudKit.Instance.PrivateDB.ActionRecordSaved += Database_ActionRecordSaved; } else { ISN_Logger.Log("Database_ActionRecordFetchComplete, Error: " + res.Error.Code + " / " + res.Error.Message); } }