IEnumerator CreateAssetAtom(string uniqueAtomName, string pathToAsset, string prefabName, string nameOfGameObjectToFind, AtomCreatedEvent OnAtomCreated) { yield return(new WaitForSeconds(0.5f)); Atom createdAtom = GetAtomById(uniqueAtomName); if (createdAtom == null) { SuperController.singleton.StartCoroutine(SuperController.singleton.AddAtomByType("CustomUnityAsset", uniqueAtomName, true)); yield return(new WaitWhile(() => GetAtomById(uniqueAtomName) == null)); createdAtom = GetAtomById(uniqueAtomName); } JSONStorable storable = createdAtom.GetStorableByID("asset"); storable.SetUrlParamValue("assetUrl", pathToAsset); storable.SetStringChooserParamValue("assetName", prefabName); yield return(new WaitWhile(() => GameObject.Find(nameOfGameObjectToFind) == null)); if (OnAtomCreated != null) { OnAtomCreated(createdAtom); } }
public override void Update() { base.Update(); if (headControlEnabled.val == false && alwaysLookAtMe.val == false) { return; } bool headSelected = headControl.linkToRB != null && (headControl.linkToRB.name == "MouseGrab" || headControl.linkToRB.name == "LeftHand" || headControl.linkToRB.name == "RightHand"); if (headSelected) { lastTriggered = Time.time; return; } if ((headLookingAtPlayer && dm.arousal.value > 0) || alwaysLookAtMe.val) { float behindAmount = 100f; Vector3 up = neckBone.transform.position - chestControl.transform.position; Vector3 targetOrigin = CameraTarget.centerTarget.transform.position + lookOffset; Vector3 delta = targetOrigin - headControl.transform.position; Vector3 target = CameraTarget.centerTarget.transform.position + delta.normalized * behindAmount; Quaternion lookRotation = Quaternion.LookRotation(delta, up); headControl.transform.rotation = Quaternion.Lerp(headControl.transform.rotation, lookRotation, Time.deltaTime * headTurnSpeed.val); } if (alwaysLookAtMe.val) { eyesStorable.SetStringChooserParamValue("lookMode", "Player"); } }