private BKI_CombiGestureClass SerializeToolToGesture(string identifier, BKI_SingleGestureClass lhGes, BKI_SingleGestureClass rhGes) { BKI_CombiGestureClass returnVal = new BKI_CombiGestureClass(); returnVal.SetValues(identifier, lhGes, rhGes); return(returnVal); }
// Saves combination public void SaveToList(BKI_CombiGestureClass bk, bool isOverwrite = false) { BKI_CombiGestureStruct struc = new BKI_CombiGestureStruct(bk); if (!EntryAlreadyExists(bk)) { if (isOverwrite) { foreach (var item in combiGesturesList) { if (item.gesture.gestureIdentifier == bk.gestureIdentifier) { combiGesturesList.Remove(item); break; } } if (combiDictionary.ContainsKey(bk.gestureIdentifier)) { combiDictionary.Remove(bk.gestureIdentifier); } } combiGesturesList.Add(struc); combiDictionary.Add(bk.gestureIdentifier, bk); AssetDatabase.Refresh(); EditorUtility.SetDirty(this); AssetDatabase.SaveAssets(); } }
private void DeserializeSavedGestureToTool(BKI_CombiGestureClass cGes) { lhGesture = cGes.leftHandGesture; rhGesture = cGes.rightHandGesture; lhMirror = DeserializeGesture(lhGesture); rhMirror = DeserializeGesture(rhGesture); }
private BKI_CombiGestureClass SaveObjectToResources(BKI_CombiGestureClass o) { string path = RESOURCES_COMBI_PATH + "/combiGes_" + o.gestureIdentifier + ".asset"; AssetDatabase.CreateAsset(o, path); //AssetDatabase.AddObjectToAsset(o.leftHandGesture, o); //AssetDatabase.AddObjectToAsset(o.rightHandGesture, o); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); BKI_CombiGestureClass returnVal = AssetDatabase.LoadAssetAtPath <BKI_CombiGestureClass>(path); return(returnVal); }
public override bool Equals(object o) { if (o == null) { return(false); } BKI_CombiGestureClass other = o as BKI_CombiGestureClass; if (other == null) { return(false); } return(this.GetHashCode() == other.GetHashCode()); }
// Starts the saving sequence of the combination gesture. private void SubmitCombinationGesture(BKI_CombiGestureClass ges, bool fromResources) { if (gestureStorage == null) { Debug.LogError("Gesture storage could not be found. Exiting save function."); return; } if (!gestureStorage.EntryAlreadyExists(ges) || fromResources) { //ges.leftHandGesture = //ges.rightHandGesture = BKI_SingleGestureClass lh = SubmitSingleHandGesture(BKI_Hand.left, ges.leftHandGesture, isOpenedFromResourcesLh); BKI_SingleGestureClass rh = SubmitSingleHandGesture(BKI_Hand.right, ges.rightHandGesture, isOpenedFromResourcesRh); BKI_CombiGestureClass g = SaveObjectToResources(ges); g.leftHandGesture = lh; g.rightHandGesture = lh; gestureStorage.SaveToList(g, fromResources); } }
public BKI_CombiGestureStruct(BKI_CombiGestureClass gesture) { this.gesture = gesture; }
public bool EntryAlreadyExists(BKI_CombiGestureClass bk) { return(combiDictionary.ContainsKey(bk.gestureIdentifier)); }
private void CatchPickerObject(object o, BKI_UIType ls) { if (o == null) { return; } switch (ls) { case BKI_UIType.left: BKI_SingleGestureClass t = o as BKI_SingleGestureClass; if (t == null) { Debug.LogError("Object invalid. Stopping opening."); break; } if (t.hand != BKI_Hand.left) { Debug.LogError("You tried to open a right handed gesture into the left hand editor. Stopping opening."); break; } lhGesture = ScriptableObject.Instantiate(t); leftHandValues = DeserializeGesture(lhGesture); lhMirror = DeserializeGesture(lhGesture); isOpenedFromResourcesLh = true; currentGestureSavedLh = true; pickerWindowGNameLh = t.gestureIdentifier; break; case BKI_UIType.right: BKI_SingleGestureClass u = o as BKI_SingleGestureClass; if (u == null) { Debug.LogError("Object invalid. Stopping opening."); break; } if (u.hand != BKI_Hand.right) { Debug.LogError("You tried to open a left handed gesture into the left hand editor. Stopping opening."); break; } rhGesture = ScriptableObject.Instantiate(u); rightHandValues = DeserializeGesture(rhGesture); rhMirror = DeserializeGesture(rhGesture); isOpenedFromResourcesRh = true; currentGestureSavedRh = true; pickerWindowGNameRh = u.gestureIdentifier; break; case BKI_UIType.combi: BKI_CombiGestureClass ges = o as BKI_CombiGestureClass; if (ges == null) { Debug.LogError("Object invalid. Stopping opening."); break; } if (!ges.name.Contains("combi")) { Debug.LogError("You tried to open a gesture other than a combination gesture. Terminating."); break; } combiGesture = ScriptableObject.Instantiate(ges); CatchPickerObject(combiGesture.leftHandGesture, BKI_UIType.left); CatchPickerObject(combiGesture.rightHandGesture, BKI_UIType.right); pickerWindowGNameCombi = ges.gestureIdentifier; currentGestureSavedCombi = true; isOpenedFromResourcesCombi = true; break; } }