public void FlipViaRotate(Gesture gesture) { if (gesture.pickedObject.tag == "PuppetBaseObject") // select intended target - this needs to be consistent //float currentXScale = //float currentXRotation = puppetBaseController.transform.localRotation.x; //float currentYRotation = puppetBaseController.transform.localRotation.y; //float currentZRotation = puppetBaseController.transform.localRotation.z; //iTween.ScaleTo(puppetBaseController,iTween.Hash("name", "flipX", "x", -currentXScale, "y", currentYScale, "z", currentZScale, "time", flipSpeed, "EaseType", "EaseInQuad")); { iTween.RotateTo(puppetRoot, iTween.Hash( "rotation", new Vector3(0f, yRot, 0f), "time", .5f, "onstart", "toggleIsKinematic", "onstarttarget", gameObject, "oncompletetarget", gameObject, "oncomplete", "toggleIsKinematic" ) ); flipCount = flipCount + 1; if (flipCount % 2 != 0) { Debug.Log("Puppet is rotated - we better invert some of the controls"); twister = puppetBaseObject.GetComponent <QuickTwist>(); twister.inverseAxisValue = true; yRot = 0f; } else { twister = puppetBaseObject.GetComponent <QuickTwist>(); twister.inverseAxisValue = false; yRot = 180f; } //transform.localScale = new Vector3( -transform.localScale.x, transform.localScale.y, transform.localScale.z); // notes local transform the root means there is an ofset if the heirarchy has moved away from the root. Instead - restructure the // heirarchy and use local transform on the base controller... Debug.Log("You're rotating the Puppet"); //Rigidbody2D myRigidbody; //myRigidbody = puppetBaseObject.GetComponent<Rigidbody2D>(); //myRigidbody.MoveRotation(180); //gesture.pickedObject } else { // pinching in space //Debug.Log("Picked Object:"+gesture.pickedObject.name+" on layer "+gesture.pickedObject.layer); } }
public override void OnInspectorGUI() { QuickTwist t = (QuickTwist)target; EditorGUILayout.Space(); t.quickActionName = EditorGUILayout.TextField("Quick name", t.quickActionName); EditorGUILayout.Space(); t.isGestureOnMe = EditorGUILayout.ToggleLeft("Gesture over me", t.isGestureOnMe); t.enablePickOverUI = EditorGUILayout.ToggleLeft("Allow over UI Element", t.enablePickOverUI); EditorGUILayout.Space(); t.actionTriggering = (QuickTwist.ActionTiggering)EditorGUILayout.EnumPopup("Triggering", t.actionTriggering); t.rotationDirection = (QuickTwist.ActionRotationDirection)EditorGUILayout.EnumPopup("Twist direction", t.rotationDirection); EditorGUILayout.Space(); if (t.actionTriggering == QuickTwist.ActionTiggering.InProgress) { t.enableSimpleAction = EditorGUILayout.Toggle("Enable simple action", t.enableSimpleAction); if (t.enableSimpleAction) { EditorGUI.indentLevel++; t.directAction = (QuickSwipe.DirectAction)EditorGUILayout.EnumPopup("Action", t.directAction); t.axesAction = (QuickSwipe.AffectedAxesAction)EditorGUILayout.EnumPopup("Affected axes", t.axesAction); t.sensibility = EditorGUILayout.FloatField("Sensibility", t.sensibility); t.inverseAxisValue = EditorGUILayout.Toggle("Inverse axis", t.inverseAxisValue); EditorGUI.indentLevel--; } } EditorGUILayout.Space(); serializedObject.Update(); SerializedProperty twistAction = serializedObject.FindProperty("onTwistAction"); EditorGUILayout.PropertyField(twistAction, true, null); serializedObject.ApplyModifiedProperties(); if (GUI.changed) { EditorUtility.SetDirty(t); #if UNITY_5_5 || UNITY_5_6 EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); #endif } }
//public float speed; public void FlipViaScale(Gesture gesture) { // improvement: dynamically parent all non-controller children // to controller 1 on flipviascale... //float originalPuppetRootXPosition = puppetRoot.transform.position.x; //float originalpuppetBaseXObject = puppetBaseObject.transform.position.x; //if (gesture.pickedObject.tag == "PuppetBaseObject" ) { // select intended target - this needs to be consistent // commented out due to remote workings - clicking on controller to flip BEWARE weirdness //float currentXScale = float currentXScale = puppetBaseController.transform.localScale.x; float currentYScale = puppetBaseController.transform.localScale.y; float currentZScale = puppetBaseController.transform.localScale.z; // the reparenting is in response to a varied heirarchy in // PuppetRoot_Wayang_Spring_Network_MT- Less Heirarchy // the arrangement gives additional physical simulation // but items need to be dynamicially reparent prior to 'flipping' via scale //LeanTween.move(); //ReparentObjects(); //LeanTween.scaleX(puppetBaseController, -currentXScale, flipSpeed); //UnparentObjects(); //LeanTween.scaleX(puppetBaseController, -currentXScale, flipSpeed).setOnStart( ()=>{ ReparentObjects(); }).setOnComplete( ()=> {UnparentObjects();});; if (flipX == true && flipY == false) { //Debug.Log("You're flipping the Puppet on X"); iTween.ScaleTo(puppetBaseController, iTween.Hash( "name", "flipX", "x", -currentXScale, "y", currentYScale, "z", currentZScale, "time", flipSpeed, "EaseType", "EaseInQuad", "oncomplete", "UnparentObjects", "onstart", "ReparentObjects", "onstarttarget", gameObject, "oncompletetarget", gameObject ) ); } if (flipY == true && flipX == false) { //Debug.Log("You're flipping the Puppet on Y"); iTween.ScaleTo(puppetBaseController, iTween.Hash( "name", "flipY", "x", currentXScale, "y", -currentYScale, "z", currentZScale, "time", flipSpeed, "EaseType", "EaseInQuad", "oncomplete", "UnparentObjects", "onstart", "ReparentObjects", "onstarttarget", gameObject, "oncompletetarget", gameObject ) ); } if (flipY == true && flipX == true) { //Debug.Log("You're flipping the Puppet on XY"); iTween.ScaleTo(puppetBaseController, iTween.Hash( "name", "flipXY", "x", -currentXScale, "y", -currentYScale, "z", currentZScale, "time", flipSpeed, "EaseType", "EaseInQuad", "oncomplete", "UnparentObjects", "onstart", "ReparentObjects", "onstarttarget", gameObject, "oncompletetarget", gameObject ) ); } flipCount = flipCount + 1; if (flipCount % 2 != 0) { //Debug.Log("Puppet is flipped - we better invert some of the controls"); twister = puppetBaseObject.GetComponent <QuickTwist>(); twister.inverseAxisValue = true; } else { twister = puppetBaseObject.GetComponent <QuickTwist>(); twister.inverseAxisValue = false; } //transform.localScale = new Vector3( -transform.localScale.x, transform.localScale.y, transform.localScale.z); // notes local transform the root means there is an ofset if the heirarchy has moved away from the root. Instead - restructure the // heirarchy and use local transform on the base controller... //Debug.Log("You're flipping the Puppet"); //Rigidbody2D myRigidbody; //myRigidbody = puppetBaseObject.GetComponent<Rigidbody2D>(); //myRigidbody.MoveRotation(180); //gesture.pickedObject }