/// <summary> /// Called when it starts to be grabbed. /// </summary> internal void OnGrabStart() { Collider cd = GetComponent <Collider>(); if (cd != null) { cd.isTrigger = true; } Rigidbody rb = GetComponent <Rigidbody>(); if (rb != null) { rb.useGravity = false; rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; rb.Sleep(); } if (Grab.Instance.UseMaterialChange) { if (m_useOutlineMaterial) { Renderer renderer = GetComponent <Renderer>(); Material[] mats = renderer.materials; if (mats[1].HasProperty("_OutlineColor")) { mats[1].SetColor("_OutlineColor", m_grabbedOutlineColor); } renderer.materials = mats; } else if (m_grabbedMaterial != null) { GetComponent <Renderer>().material = m_grabbedMaterial; } } foreach (GrabCollider gc in m_grabColliders) { gc.SetLock(true); } //Jiaju change FoamScaleTab tab = this.GetComponent <FoamScaleTab>(); if (tab) { tab.OnGrabStart(); } Modelable modelable = this.GetComponent <Modelable>(); if (modelable) { modelable.OnGrabStart(); } }
/// <summary> /// Called when it stops to be grabbed. /// </summary> internal void OnGrabStop(Vector3 releaseVelocity) { Collider cd = GetComponent <Collider>(); if (cd != null) { cd.isTrigger = false; } Rigidbody rb = GetComponent <Rigidbody>(); if (rb != null) { rb.useGravity = true; rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; rb.velocity = releaseVelocity * m_throwPower; } // material back to selected if (Grab.Instance.UseMaterialChange) { if (m_useOutlineMaterial) { Renderer renderer = GetComponent <Renderer>(); Material[] mats = renderer.materials; if (mats[1].HasProperty("_OutlineColor")) { mats[1].SetColor("_OutlineColor", m_selectedOutlineColor); } renderer.materials = mats; } else if (m_selectedMaterial != null) { GetComponent <Renderer>().materials = new Material[] { m_selectedMaterial }; } } //Jiaju change FoamScaleTab tab = this.GetComponent <FoamScaleTab>(); if (tab) { tab.OnGrabStop(); } Modelable modelable = this.GetComponent <Modelable>(); if (modelable) { modelable.OnGrabStop(); } }
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { Modelable model = _copiedObj.GetComponent <Modelable>(); if (model) { model.SetAsSelected(); } // undo redo ICommand copyAction = new CommandCreateCopy(_copiedObj.gameObject, _data); UndoRedoManager.AddNewAction(copyAction); }
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { //Debug.Log("EXITING CREATION MENU SELECTED STATE"); Modelable model = m_prim.gameObject.GetComponent <Modelable>(); if (model) { model.SetAsSelected(); } // undo redo ICommand createAction = new CommandCreateCopy(m_prim.gameObject, m_data); UndoRedoManager.AddNewAction(createAction); animator.SetBool(m_hash_itemSelectedBool, false); m_prim = null; }
void OnTriggerEnter(Collider other) { // Don't want palm if (other.name == "palm") { return; } if (other.transform.parent == null || other.transform.parent.parent == null) { return; } if (other.transform.parent.parent.name == "Hand_l") { if (other.transform.parent.name != "ring" && other.transform.parent.name != "pinky") { m_leftHandFingerIn++; } } else if (other.transform.parent.parent.name == "Hand_r") { if (other.transform.parent.name != "ring" && other.transform.parent.name != "pinky") { m_rightHandFingerIn++; } } // meaningless if it's already entered. if (m_entered) { return; } // if it's locked, don't change anything if (m_ableToExpand == false) { return; } // Jiaju FoamAR addition //if (!FoamUtils.IsGlobalGrabbing) return; if (FoamUtils.ShouldStopGrabCollider(this.transform.parent.gameObject)) { return; } if (m_leftHandFingerIn >= FINGER_THRESHOLD) { // Jiaju Modelable model = _parentGameObject.GetComponent <Modelable>(); if (model) { model.SetAsSelected(); } } else if (m_rightHandFingerIn >= FINGER_THRESHOLD) { // Jiaju Modelable model = _parentGameObject.GetComponent <Modelable>(); if (model) { model.SetAsSelected(); } // Tell it to be grabbed if (m_grabObj != null) { m_grabObj.OnGrabTriggerEnter(this, false); m_entered = true; Expand(other.transform.parent.parent); } } }
public ActionGenerator(string projectName, Action modelParameters, IList <Modelable> operations, ActionBaseGenerator actionBase) : base(projectName, "Actions", modelParameters.Name + "Action", typeof(ActionTemplate), modelParameters, modelParameters.Name) { ActionBase = actionBase; Operation = operations.FirstOrDefault(x => x.Key.Equals(modelParameters.Operation.Name)); Key = modelParameters.Name; }