public static T FindComponent <T>(this UnityEngine.GameObject g, bool in_parent = true, bool in_children = true, int sibling_depth = 0, bool ignore_self = false) where T : Component { if (ignore_self) { if (in_children) { foreach (Transform child in g.transform) { if (child.GetComponentInChildren <T>()) { return(child.GetComponentInChildren <T>()); } } } if (in_parent) { return(g.transform.parent.GetComponentInParent <T>()); } } if (g.GetComponent <T>() != null) { return(g.GetComponent <T>()); } if (in_children && g.GetComponentInChildren <T>() != null) { return(g.GetComponentInChildren <T>()); } if (in_parent) { if (g.GetComponentInParent <T>() != null) { return(g.GetComponentInParent <T>()); } } UnityEngine.GameObject current = g; while (sibling_depth > 0) { current = current.transform.parent.gameObject; if (!current) { break; } if (current.GetComponentInChildren <T>() != null) { return(current.GetComponentInChildren <T>()); } sibling_depth--; } return(g.GetComponent <T>()); }
public virtual void OnExit(GameObject exited) { Entity e = exited.GetComponentInParent<Entity>(); if (e) { entitiesInContact.Remove(e); } }
void OnParticleCollision(GameObject shooter) { //print ( "OnParticleCollision " + other.transform.root.name + " ME : " + transform.root.name); shooterCombat = shooter.transform.root.GetComponent<Combat>(); if (shooterCombat != myCombat && shooterCombat.isLocalPlayer) { shooterCombat.GiveDamage ( shooter.GetComponentInParent<Weapon>().damage , transform.root.name , DamageType.Smell , Vector3.zero , Vector2.zero ); //myCombat.TakeDamage ( shooter.GetComponentInParent<Weapon>().damage , transform.root.name , DamageType.Smell , Vector3.zero , Vector2.zero ); } }
void Awake() { On("OnMainCameraChange"); _healthContainer = GetComponentInChildren<Image>().gameObject; _healthContainer.GetComponentInParent<Canvas>().worldCamera = Camera.main; _rectTransform = _healthContainer.GetComponent<RectTransform>(); _healthBar = _healthContainer.transform.FindChild("HealthBar").GetComponent<RectTransform>(); _image = _healthBar.GetComponent<Image>(); _krHealth = transform.GetComponentInParent<KRHealth>(); }
//------------------------------------------------- void OnCollisionEnter(Collision other) { Balloon contactBalloon = other.collider.GetComponentInParent <Balloon>(); if (contactBalloon != null) { Hand hand = physParent.GetComponentInParent <Hand>(); if (hand != null) { hand.controller.TriggerHapticPulse(500); } } }
public bool TryToPickup(GameObject obj) { var new_item = obj.GetComponent<Rigidbody> (); if (new_item == null) new_item = obj.GetComponentInParent<Rigidbody> (); if (new_item != null && !new_item.isKinematic) { Pickup (new_item); return true; } else { Debug.Log ("Can't pick up " + obj.name); return false; } }
public virtual void OnTouch(GameObject touched) { Entity e = touched.GetComponentInParent<Entity>(); if (e) { if (!entitiesInContact.Contains(e)) { attack.Execute(DamageInfo.DamageType.physical, damageModifierOnTouch, e); entitiesInContact.Add(e); StartCoroutine(_OnContinuousTouch(e)); } } }
static public int GetComponentInParent(IntPtr l) { try { UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l); System.Type a1; checkType(l, 2, out a1); var ret = self.GetComponentInParent(a1); pushValue(l, ret); return(1); } catch (Exception e) { return(error(l, e)); } }
protected IInteractionActor GetActor(GameObject other) { if (!_cachedActorMap.ContainsKey(other)) { // cache miss - grab from other object using GetComponent IInteractionActor actor = other.GetComponentInParent<IInteractionActor>(); if (actor == null) { Debug.LogError("InteractionZone entered by GameObject without InteractionZoneActor script"); return null; } _cachedActorMap[other] = actor; } return _cachedActorMap[other]; }
static public int GetComponentInParent(IntPtr l) { try{ UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l); System.Type a1; checkType(l, 2, out a1); UnityEngine.Component ret = self.GetComponentInParent(a1); pushValue(l, ret); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static int GetComponentInParent(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject)); System.Type arg0 = (System.Type)ToLua.CheckObject(L, 2, typeof(System.Type)); UnityEngine.Component o = obj.GetComponentInParent(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private static void SetupObject(string objectName) { selectedObject = Selection.activeGameObject; theThing.name = objectName; if (selectedObject) { if (GameObject.Find(selectedObject.name)) { if (selectedObject.GetComponentInParent<Canvas>()) notCanvas = false; else notCanvas = true; } else notCanvas = true; } else notCanvas = true; if (notCanvas) { if (!GameObject.FindObjectOfType<UnityEngine.EventSystems.EventSystem>()) { GameObject.Instantiate(AssetDatabase.LoadAssetAtPath("Assets/MaterialUI/ComponentPrefabs/EventSystem.prefab", typeof (GameObject))).name = "EventSystem"; } if (GameObject.FindObjectOfType<Canvas>()) { selectedObject = GameObject.FindObjectOfType<Canvas>().gameObject as GameObject; } else { selectedObject = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath("Assets/MaterialUI/ComponentPrefabs/Canvas.prefab", typeof (GameObject))) as GameObject; selectedObject.name = "Canvas"; } } theThing.transform.SetParent(selectedObject.transform); theThing.transform.localPosition = Vector3.zero; theThing.transform.localScale = new Vector3(1, 1, 1); Selection.activeGameObject = theThing; }
public static int GetComponentInParent_wrap(long L) { try { long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L); UnityEngine.GameObject obj = get_obj(nThisPtr); System.Type arg0 = FCGetObj.GetObj <System.Type>(FCLibHelper.fc_get_wrap_objptr(L, 0)); UnityEngine.Component ret = obj.GetComponentInParent(arg0); long ret_ptr = FCLibHelper.fc_get_return_ptr(L); long v = FCGetObj.PushObj(ret); FCLibHelper.fc_set_value_wrap_objptr(ret_ptr, v); } catch (Exception e) { Debug.LogException(e); } return(0); }
private ItemInfo GetItemInfo(GameObject selected) { if (selected == null) return null; foreach (var info in _items) { if (info.Control == selected) return info; } //we only use the first parent, in the case of nested listboxes var parentItem = selected.GetComponentInParent<ListBoxItem>(); var parent = parentItem == null ? null : parentItem.gameObject; foreach(var info in _items) { if (info.Control == parent) return info; } return null; }
void Start () { cameraAudio = GetComponent<AudioSource> (); parent = GameObject.Find("PlayerCam"); cameraHeldUp = new Vector3( 0.009f, 0.030f,-0.100f); cameraHeldDown = new Vector3( 0.293f,-0.499f, 0.300f); photoReview = false; // Set portrait lens /*curLens = GameObject.Find (currentLens); curLens.GetComponent<MeshRenderer> ().enabled = true; parent.GetComponentInParent<DepthOfField> ().focalSize = curLens.GetComponent<Lens> ().focalSize; parent.GetComponentInParent<DepthOfField> ().focalLength = curLens.GetComponent<Lens> ().focalDistance; parent.GetComponentInParent<Camera> ().fieldOfView = curLens.GetComponent<Lens> ().fieldOfView; */ FilterPrefab.SetActive (false); lensIter = 0; filterIter = 0; memCardReader = GameObject.Find("/MemoryCardManager").GetComponent<MemoryCardReader>(); PlayerProfile.profile.load (); currentLens = PlayerProfile.profile.lensesInBag[0]; curLens = GameObject.Find (currentLens); curLens.GetComponent<MeshRenderer> ().enabled = true; parent.GetComponentInParent<DepthOfField> ().focalSize = curLens.GetComponent<Lens> ().focalSize; parent.GetComponentInParent<DepthOfField> ().focalLength = curLens.GetComponent<Lens> ().focalDistance; parent.GetComponentInParent<Camera> ().fieldOfView = curLens.GetComponent<Lens> ().fieldOfView; /*foreach (string s in PlayerProfile.profile.lensesInBag) { Debug.Log ("Lens " + s); } foreach (string s in PlayerProfile.profile.filtersInBag) { Debug.Log ("Filters " + s); }*/ }
private void DoCollide(GameObject collidedObject) { Collider other = collidedObject.GetComponent<Collider>(); if (ignoreColliders != null && ignoreColliders.Contains(other)) return; IInteractable interactable = collidedObject.GetComponentInParent<IInteractable>(); if (interactable != null) { if (interactable is Entity) { CharController controller = collidedObject.GetComponent<CharController>(); if (controller) controller.Hit(); } float strBonus = str ? str.Value * 0.5f : 0; AttackAction attack = owner.GetComponent<AttackAction>(); if (attack) attack.Execute(strBonus, interactable); } SimulateImpact(collidedObject, impactMultiplier, true); }
/// <summary> /// The IsObjectInteractable method is used to check if a given game object is of type `VRTK_InteractableObject` and whether the object is enabled. /// </summary> /// <param name="obj">The game object to check to see if it's interactable.</param> /// <returns>Is true if the given object is of type `VRTK_InteractableObject`.</returns> public bool IsObjectInteractable(GameObject obj) { if (obj) { var io = obj.GetComponent<VRTK_InteractableObject>(); if (io) { return io.enabled; } else { io = obj.GetComponentInParent<VRTK_InteractableObject>(); if (io) { return io.enabled; } } } return false; }
///////////////////////////////////////// // OnEntityBuilt(Planner planner, GameObject gameobject) // Called when a buildingblock was created ///////////////////////////////////////// private void OnEntityBuilt(Planner planner, GameObject gameobject) { if (planner.ownerPlayer == null) return; if (HasPlayerFlag(planner.ownerPlayer, ZoneFlags.NoBuild) && !hasPermission(planner.ownerPlayer, PermCanBuild)) { gameobject.GetComponentInParent<BaseCombatEntity>().Kill(BaseNetworkable.DestroyMode.Gib); SendMessage(planner.ownerPlayer, "You are not allowed to build here"); } }
private void SetupPosesListView(List <HVRHandPose> poses) { var posesParent = GameObject.Find("RecordedPosesCloneHolder"); if (!posesParent) { posesParent = new GameObject("RecordedPosesCloneHolder"); } foreach (Transform child in posesParent.transform) { DestroyImmediate(child.gameObject); } Poses = poses; var listview = _root.Q <ScrollView>("RecordedPoses"); listview.Clear(); foreach (var pose in poses) { var row = new VisualElement(); row.AddToClassList("poserow"); var field = new ObjectField("Pose:"); field.objectType = typeof(HVRHandPose); field.value = pose; row.Add(field); field.AddToClassList("poserow-field"); var clone = Instantiate(HVRSettings.Instance.GetPoserHand(pose.SnappedLeft ? HVRHandSide.Left : HVRHandSide.Right), posesParent.transform, true); var posableHand = clone.GetComponent <HVRPosableHand>(); if (posableHand != null) { posableHand.Pose(pose); } var attach = new Button(() => { if (!SelectedGrabPoints) { EditorUtility.DisplayDialog("Error!", "Please set GrabPoints field.", "Ok!"); return; } var grabPoint = new GameObject("GrabPoint"); grabPoint.transform.parent = SelectedGrabPoints.transform; grabPoint.transform.localPosition = Vector3.zero; var poser = grabPoint.AddComponent <HVRHandPoser>(); var posable = grabPoint.AddComponent <HVRPosableGrabPoint>(); posable.HandPoser = poser; grabPoint.transform.localPosition = Vector3.zero;//.position = pose.SnappedLeft ? pose.LeftHand.Position : pose.RightHand.Position; grabPoint.transform.localRotation = Quaternion.identity; var clonedPose = posableHand.CreateFullHandPose(posableHand.MirrorAxis); clonedPose.RightHand.Rotation = Quaternion.Inverse(grabPoint.transform.rotation) * clonedPose.RightHand.Rotation; clonedPose.LeftHand.Rotation = Quaternion.Inverse(grabPoint.transform.rotation) * clonedPose.LeftHand.Rotation; clonedPose.RightHand.Position = Vector3.zero; clonedPose.LeftHand.Position = Vector3.zero; poser.PrimaryPose = new HVRHandPoseBlend(); poser.PrimaryPose.Pose = clonedPose; poser.PrimaryPose.SetDefaults(); var grabbable = grabPoint.GetComponentInParent <HVRGrabbable>(); string name; if (grabbable) { name = grabbable.name + "-" + pose.name; } else { name = DateTime.Now.Ticks.ToString(); } poser.PrimaryPose.Pose = HVRSettings.Instance.SavePoseToDefault(clonedPose, name, ""); //EditorUtility.SetDirty(pose); //AssetDatabase.SaveAssets(); //AssetDatabase.Refresh(); }) { text = "Attach" }; var delete = new Button(() => { row.RemoveFromHierarchy(); DestroyImmediate(clone); }) { text = "-" }; var focus = new Button(() => { Selection.activeGameObject = clone; SceneView.FrameLastActiveSceneView(); }) { text = "Focus" }; attach.AddToClassList("poserow-button"); delete.AddToClassList("poserow-button"); focus.AddToClassList("poserow-button"); row.Add(focus); row.Add(attach); row.Add(delete); listview.Insert(listview.childCount, row); } }
private static bool CreateGameObject(out GameObject created) { created = Selection.activeGameObject; if (created != null && created.GetComponentInParent<Canvas>() != null && EditorApplication.ExecuteMenuItem("GameObject/Create Empty Child")) { created = Selection.activeGameObject; return true; } else if (EditorApplication.ExecuteMenuItem("GameObject/UI/Image")) { created = Selection.activeGameObject; GameObject.DestroyImmediate(created.GetComponent<Image>()); GameObject.DestroyImmediate(created.GetComponent<CanvasRenderer>()); return true; } else { return false; } }
GameObject ExtractRootParentFrom(GameObject theObject) { // try to get the player GameObject from this Flowchart's GameObject Persona personaScript = theObject.GetComponent<Persona>(); // if it wasn't there if (personaScript == null) { // try to get the Persona from this flowchart's parents personaScript = theObject.GetComponentInParent<Persona>(); } // if we found the Persona component if (personaScript != null) { // return it's GameObject return personaScript.gameObject; } // couldn't find it (this is an error Debug.LogError("Couldn't find root parent object"); return null; }
private bool IsColliderChildOfTouchedObject(GameObject collider) { if (touchedObject != null && collider.GetComponentInParent<VRTK_InteractableObject>() && collider.GetComponentInParent<VRTK_InteractableObject>().gameObject == touchedObject) { return true; } return false; }
public Loot(GameObject agent, GameObject cell) : base(agent, TaskType.Loot) { this.cell = cell; hive = cell.GetComponentInParent<HiveWarehouse>(); }
public static Component GetComponentInParent0T(this UnityEngine.GameObject self, System.Type T) { return(self.GetComponentInParent(T)); }
/// <summary> /// Finds the part by the GameObject belongs to. /// </summary> /// <param name="gameObject">GameObject of a part</param> /// <returns>the part</returns> /// <remarks>Thanks goes to xEvilReeperx! :-)</remarks> /// <see cref="http://forum.kerbalspaceprogram.com/threads/7544-The-official-unoffical-help-a-fellow-plugin-developer-thread?p=2124761&viewfull=1#post2124761"/> public Part GetPartByGameObject(GameObject gameObject) { return gameObject.GetComponentInParent<Part>(); }
public bool CanBuild(GameObject hierarchySelection) { Canvas parentCanvas = hierarchySelection.GetComponentInParent<Canvas>(); return parentCanvas != null; }
public virtual void MouseClick(GameObject hitGameObject, Vector3 hitPoint, Player player) { if (isSelected == false) { return; } if (hitGameObject == null) { return; } bool isGround = hitGameObject.CompareTag(Tags.GROUND); if (isGround == true) { return; } Destructible hitEntity = hitGameObject.GetComponentInParent<Destructible>(); if (hitEntity == null) { return; } if (hitEntity == this) { return; } bool readyToAttack = IsAbleToAttack(); if (readyToAttack == false) { ChangeSelection(hitEntity, player); return; } if (hitEntity.MaxHitPoints == 0) { ChangeSelection(hitEntity, player); return; } Player hitEntityOwner = hitEntity.Owner; if (hitEntityOwner != null) { bool samePlayer = Owner.PlayerId == hitEntityOwner.PlayerId; if (samePlayer == true) { ChangeSelection(hitEntity, player); return; } } SetAttackTarget(hitEntity); }
private static void CreateToolTipItem(bool select, GameObject parent) { var btti = Object.FindObjectOfType<BoundTooltipItem>(); if (btti == null) { var boundTooltipItem = CreateUIObject("ToolTipItem", parent.GetComponentInParent<Canvas>().gameObject); btti = boundTooltipItem.AddComponent<BoundTooltipItem>(); var boundTooltipItemCanvasGroup = boundTooltipItem.AddComponent<CanvasGroup>(); boundTooltipItemCanvasGroup.interactable = false; boundTooltipItemCanvasGroup.blocksRaycasts = false; var boundTooltipItemImage = boundTooltipItem.AddComponent<Image>(); boundTooltipItemImage.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>(kBackgroundSpriteResourcePath); var boundTooltipItemText = CreateUIObject("Text", boundTooltipItem); var boundTooltipItemTextRT = boundTooltipItemText.GetComponent<RectTransform>(); boundTooltipItemTextRT.anchorMin = Vector2.zero; boundTooltipItemTextRT.anchorMax = Vector2.one; boundTooltipItemTextRT.sizeDelta = Vector2.one; var boundTooltipItemTextcomponent = boundTooltipItemText.AddComponent<Text>(); boundTooltipItemTextcomponent.alignment = TextAnchor.MiddleCenter; Undo.RegisterCreatedObjectUndo(boundTooltipItem, "Create " + boundTooltipItem.name); } if (select && btti != null) { Selection.activeGameObject = btti.gameObject; } }
/// <summary> /// Create the content of a board, which content is a set of TextButton. /// </summary> /// <param name="texts">The text array should be displayed on a set of TextButtons</param> /// <param name="buttonPrefab">prefab of the TextButton, which could be customized by developers</param> /// <param name="contentGameObject">parent GameObject that the created a set of TextButtons should be child of</param> /// <param name="toBottom">whether the content of board should scroll to bottom when shown</param> /// <param name="onclick">function to be called when responding TextButton is clicked</param> /// <param name="parameters">parameter array should be attached to the TextButton and would be passed to the on click function</param> public void setupTextButtonBoard(List<string> texts, GameObject buttonPrefab, GameObject contentGameObject, bool toBottom, UnityAction<bool, System.Object> onclick, List<System.Object> parameters) { //Destroy all previous text buttons for (int i = 0; i < contentGameObject.transform.childCount; i++) { GameObject.Destroy(contentGameObject.transform.GetChild(i).gameObject); } //Create a list of log text button List<GameObject> textButtons = new List<GameObject>(); for (int i = 0; i < texts.Count; i++) { GameObject newTextButton = this.createTextButton(texts[i], buttonPrefab, contentGameObject, onclick, parameters[i]); if (textButtons.Count > 0) { newTextButton.transform.localPosition = textButtons[textButtons.Count - 1].transform.localPosition; newTextButton.transform.localPosition = new Vector3(newTextButton.transform.localPosition.x, newTextButton.transform.localPosition.y - newTextButton.GetComponent<RectTransform>().rect.height*1f, newTextButton.transform.localPosition.z); } textButtons.Add(newTextButton); } //Resize the backLogText float height = (textButtons.Count + 1) * textButtons[0].GetComponent<RectTransform>().rect.height; float width = contentGameObject.GetComponent<RectTransform>().rect.width; contentGameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(width, height); //Scroll to the bottom if (toBottom) { contentGameObject.GetComponentInParent<ScrollRect>().normalizedPosition = new Vector2(0, 0); } }
private void StopTouching(GameObject obj) { if (IsObjectInteractable(obj)) { GameObject untouched; if (obj.GetComponent<VRTK_InteractableObject>()) { untouched = obj; } else { untouched = obj.GetComponentInParent<VRTK_InteractableObject>().gameObject; } OnControllerUntouchInteractableObject(SetControllerInteractEvent(untouched.gameObject)); untouched.GetComponent<VRTK_InteractableObject>().ToggleHighlight(false); untouched.GetComponent<VRTK_InteractableObject>().StopTouching(this.gameObject); } if (hideControllerOnTouch) { controllerActions.ToggleControllerModel(true, touchedObject); } touchedObject = null; }
/// <summary> /// Returns all of the ISystems that are associated with the LevelDesigner that is /// hierarchically associated with the given selected object. /// </summary> private List<ISystem> GetSystems(GameObject selected) { var designer = selected.GetComponentInParent<LevelDesigner>(); return designer.Snapshot.Systems; }
public virtual void SetHoverState(GameObject gameObjectUnderMouse) { if (Owner == null) { return; } if (Owner.IsNPC == true) { return; } if (isSelected == false) { return; } bool isGround = gameObjectUnderMouse.CompareTag(Tags.GROUND); if (isGround == true) { return; } Owner.PlayerHud.SetCursorState(CursorState.select); bool canAttack = IsAbleToAttack(); if (canAttack == false) { return; } Destructible entityUnderMouse = gameObjectUnderMouse.GetComponentInParent<Destructible>(); if (entityUnderMouse == null) { return; } if (entityUnderMouse.MaxHitPoints == 0) { return; } Player entityOwner = entityUnderMouse.Owner; if (entityOwner != null) { bool samePlayer = Owner.PlayerId == entityOwner.PlayerId; if (samePlayer == true) { return; } } Owner.PlayerHud.SetCursorState(CursorState.attack); }
///////////////////////////////////////// // OnEntityBuilt(Planner planner, GameObject gameobject) // Called when a buildingblock was created ///////////////////////////////////////// void OnEntityBuilt(Planner planner, GameObject gameobject) { if (planner.ownerPlayer == null) return; if (hasTag(planner.ownerPlayer, "nobuild")) { if (!hasPermission(planner.ownerPlayer, "canbuild")) { gameobject.GetComponentInParent<BaseCombatEntity>().Kill(BaseNetworkable.DestroyMode.Gib); SendMessage(planner.ownerPlayer, "You are not allowed to build here"); } } }
private void SimulateImpact(GameObject other, Vector2 multiplier, bool zeroVelocity = false) { Rigidbody body = other.GetComponentInParent<Rigidbody>(); if (body) { if (zeroVelocity) body.velocity = Vector3.zero; Vector3 dir = other.transform.position - transform.position; dir.y = 0; dir.Normalize(); float strModifier = str ? str.Value : 1; body.AddForce((dir * multiplier.x + Vector3.up * multiplier.y) * strModifier, modeOnImpact); } }
private bool ShouldIgnoreElement(GameObject obj, string ignoreCanvasWithTagOrClass, VRTK_TagOrScriptPolicyList canvasTagOrScriptListPolicy) { var canvas = obj.GetComponentInParent<Canvas>(); if (!canvas) { return false; } return (Utilities.TagOrScriptCheck(canvas.gameObject, canvasTagOrScriptListPolicy, ignoreCanvasWithTagOrClass)); }
/// <summary> /// Attempts to hit an object by raycast onto it first, then /// destroying that ship part (if ship part) and applies a force /// in the direction of this game object's forward vector /// </summary> /// <param name="a_gameObject">Which game object to alert of collisions</param> private void HitObject(GameObject a_gameObject) { RaycastHit raycastHit; if (!Physics.Raycast(m_transform.position, m_transform.forward, out raycastHit, m_collider.height, collisionLayerMask)) { // Didn't collide with object return; } // Get player rigid body Rigidbody objectRigidBody = a_gameObject.GetComponentInParent<Rigidbody>(); if (objectRigidBody == null) { Debug.Log("Can't find rigid body on collided object"); } // Apply colliding force to player objectRigidBody.AddForce(m_transform.forward * collisionForce, ForceMode.Impulse); Debug.Log("Cannon ball collided with: " + objectRigidBody.name + " (tag: " + objectRigidBody.tag + ")"); // Attempt to destroy player part ShipPartDestroy partDestroyer = a_gameObject.GetComponentInParent<ShipPartDestroy>(); if (partDestroyer == null) { // Not destructable player part return; } // Destroy player part partDestroyer.EvaluatePartCollision(a_gameObject.GetComponent<Collider>(), collisionForce * 2.0f); }
public bool IsObjectInteractable(GameObject obj) { return (obj && (obj.GetComponent<VRTK_InteractableObject>() || obj.GetComponentInParent<VRTK_InteractableObject>())); }
void setQuit() { // 游戏的外环顺时针旋转; mGo_Quit_parent.transform.localPosition = Vector3.zero; GameObject go = mGo_Quit_parent.transform.FindChild("fruitparent/ring").gameObject; Framework.SetRotate(go, 10f, true); Framework.SetScale(go); AddRing(go); // 游戏的水果逆时针旋转; Vector3 vec = mGo_Quit_parent.transform.FindChild("fruitparent").localPosition; if(mGo_Quit==null) { mGo_Quit = Framework.CreateUIFruit(mGo_Quit_parent, fruitType.boom, vec); FruitItem fuit = mGo_Quit.GetComponentInParent<FruitItem>(); Framework.AddOnClick(mGo_Quit, "", OnQuit); } }