GetComponentsInChildren() public method

public GetComponentsInChildren ( Type type ) : UnityEngine.Component[]
type System.Type
return UnityEngine.Component[]
Example #1
0
 public void ClearTextsAndSprite(GameObject _targ)
 {
     new OTTween(DarkBG, 1f).Tween("alpha", 0f);
     if (_targ.GetComponentsInChildren<OTSprite>() != null)
     {
         foreach (OTSprite _spr in _targ.GetComponentsInChildren<OTSprite>())
         {
             _spr.alpha = 0f;
         }
     }
     if (_targ.GetComponentsInChildren<TextUI>() != null)
     {
         foreach (TextUI _txt in _targ.GetComponentsInChildren<TextUI>())
         {
             _txt.makeFadeOut();
         }
     }
     if (_targ.GetComponentsInChildren<UIBtn>() != null)
     {
         foreach (UIBtn _btn in _targ.GetComponentsInChildren<UIBtn>())
         {
             _btn.reDisable();
         }
     }
 }
Example #2
0
    void OnPostprocessModel(GameObject go)
    {
        MeshRenderer[] meshComponents = go.GetComponentsInChildren<MeshRenderer>();
        SkinnedMeshRenderer[] skinMeshComponents = go.GetComponentsInChildren<SkinnedMeshRenderer>();

        bool isAnim = false;
        if(meshComponents.Length == 0 && skinMeshComponents.Length == 0)
        {
            isAnim = true;
        }

        ModelImporter importer = assetImporter as ModelImporter;
        if(isAnim)
        {
            importer.optimizeMesh = false;
            importer.importMaterials = false;
            importer.normalImportMode = ModelImporterTangentSpaceMode.None;
            importer.tangentImportMode = ModelImporterTangentSpaceMode.None;
            importer.splitTangentsAcrossSeams = false;
        }

        //
        importer.importAnimation = isAnim;

        go.tag = isAnim ? EAssetType.Anim.ToString() : EAssetType.Model.ToString();
    }
Example #3
0
    void OnMouseDown()
    {
        if (!GameObject.Find ("Popup(Clone)") && !GameObject.Find ("Map(Clone)") && !GameObject.Find ("EncounterBox(Clone)") && !GameObject.Find ("gradList(Clone)") && !GameObject.Find ("gratzPop(Clone)") && !GameObject.Find ("TutorialBox(Clone)")) {
            mainVar.selectedStudent = this.name;
            Debug.Log (this);
            studentData = this.GetComponent<StudentData> ();
            if (mainVar.gameState) {
                newPopup = Instantiate (Resources.Load ("Popup"))as GameObject;
                newPopup.GetComponentsInChildren<TextMesh> () [1].text = studentData.name;
                newPopup.GetComponentsInChildren<TextMesh> () [2].text = studentData.major;
                newPopup.GetComponentsInChildren<TextMesh> () [0].text = "'" + studentData.tagline + "'";
                //			cgpaBar = studentData.CGPA;

                //			cgpaBar = (cgpaBar - 0) / (12 - 0) * (3 - 0) + 0;

                //			newPopup.GetComponentsInChildren<Transform> () [10].localScale = new Vector3 (cgpaBar, 3f, 3f);
                //			newPopup.AddComponent<BoxCollider2D> ();
                //			newPopup.layer = 5;
                //			newPopup.GetComponent<BoxCollider2D> ().isTrigger = true;
                //			newPopup.GetComponent<BoxCollider2D> ().size = new Vector2 (5, 3);

                AudioSource[] audioSources = GameObject.Find ("Main Camera").GetComponents<AudioSource> ();
                audioSources [1].Play ();

                //			newPopup.AddComponent<AudioSource>();
                //			newPopup.GetComponent<AudioSource>().clip = Resources.Load("Audio/blip") as AudioClip;
                //			newPopup.GetComponent<AudioSource>().Play ();

                newPopup.AddComponent<DestoryPopup> ();
                mainVar.gameState = false;
            }
        }

        //		Debug.Log (this.name);
    }
        public void initialise(ASPPainter painter)
        {
            _painter = painter;

            ScreenMessages.PostScreenMessage("Paint Pointer - RMB or Escape to exit", 5, ScreenMessageStyle.UPPER_CENTER);

            if (_pointer == null)
            {
                GameObject modelObject = GameDatabase.Instance.GetModel(_pointerModel).gameObject;
                _pointer = Instantiate(modelObject) as GameObject;

                Collider[] colliders = _pointer.GetComponentsInChildren<Collider>(true);
                foreach (Collider collider in colliders)
                {
                    Destroy(collider);
                }

                _meshRenderers = _pointer.GetComponentsInChildren<MeshRenderer>(true);
                foreach (MeshRenderer mesh in _meshRenderers)
                {
                    mesh.material = new Material(Shader.Find("Transparent/Diffuse"));
                }

                _pointer.SetActive(true);
            }

            GameEvents.onVesselChange.Add(new EventData<Vessel>.OnEvent(this.OnVesselChange));
        }
Example #5
0
    void Start()
    {
        if (particle != null)
        {
            GO = Instantiate(particle) as GameObject;

                GO.transform.SetParent(transform, false);

            if (autoStart)
            {
                foreach (ParticleSystem ps in GO.GetComponentsInChildren<ParticleSystem>())
                {
                    ps.loop = true;
                    ps.playOnAwake = true;
                    GO.SetActive(false);
                    GO.SetActive(true);
                }
            }
            else
            {
                foreach (ParticleSystem ps in GO.GetComponentsInChildren<ParticleSystem>())
                {
                    ps.loop = false;
                    ps.playOnAwake = false;
                    GO.SetActive(false);
                    GO.SetActive(true);
                }
            }
        }
    }
Example #6
0
    public Mesh FindMesh1(GameObject go, out GameObject obj)
    {
        if ( go )
        {
            MeshFilter[] filters = (MeshFilter[])go.GetComponentsInChildren<MeshFilter>(true);

            if ( filters.Length > 0 )
            {
                if ( filters[0].gameObject != go )
                    obj = filters[0].gameObject;
                else
                    obj = null;
                return filters[0].mesh;
            }

            SkinnedMeshRenderer[] skins = (SkinnedMeshRenderer[])go.GetComponentsInChildren<SkinnedMeshRenderer>(true);
            if ( skins.Length > 0 )
            {
                if ( skins[0].gameObject != go )
                    obj = skins[0].gameObject;
                else
                    obj = null;
                return skins[0].sharedMesh;
            }
        }

        obj = null;
        return null;
    }
Example #7
0
        /// <summary>
        /// Enables the ragdool.
        /// </summary>
        /// <remarks>
        /// The GameObject must have a Collider and a Rigidbody.
        /// </remarks>
        /// <param name="enable">If set to <c>true</c> enable.</param>
        public static void EnableRagdoll(GameObject gameObject, bool enable)
        {
            var bones = gameObject.GetComponentsInChildren<Rigidbody>();

            for (var boneIndex = 0; boneIndex < bones.Length; boneIndex++) {
                var bone = bones[boneIndex];
                var collider = bone.GetComponent<Collider>();
                if (collider != null) {
                    collider.enabled = enable;
                }
                bone.isKinematic = !enable;
                bone.mass = (enable ? 0.1f : 0.01f);
            }
            gameObject.GetComponent<Collider>().enabled = !enable;

            var rigidbody = gameObject.GetComponent<Rigidbody>();
            if (enable) {
                rigidbody.useGravity = false;
                rigidbody.isKinematic = true;
            } else {
                rigidbody.mass = 1.0f;
                rigidbody.useGravity = true;
                rigidbody.isKinematic = false;
            }

            var animators = gameObject.GetComponentsInChildren<Animator>();
            for (var animatorIndex = 0; animatorIndex < animators.Length; animatorIndex++) {
                animators[animatorIndex].enabled = !enable;
            }
        }
    protected override void InitializeDialoguePanel()
    {
        m_currentState = DialogueTreeStates.RUNNING;

        m_dialoguePanel = Instantiate((GameObject)Resources.Load("DialoguePanel", typeof(GameObject)));
        Text[] messages = m_dialoguePanel.GetComponentsInChildren<Text>();

        for(int i=0; i<messages.Length;i++)
        {
            if(messages[i].gameObject.name == "Message")
            {
                messages[i].text = m_singleMessage;
                break;
            }

        }

        Button[] buttons = m_dialoguePanel.GetComponentsInChildren<Button>();

        for (int i = 0; i < buttons.Length; i++)
        {
            if (buttons[i].gameObject.name == "ButtonOptionA")
            {
                buttons[i].onClick.AddListener(() => OnOptionClicked());
            }
            else if (buttons[i].gameObject.name == "ButtonOptionB")
            {
                buttons[i].onClick.AddListener(() => OnOptionClicked());
            }
        }
    }
Example #9
0
		void Awake(){
			thisObj=gameObject;
			thisT=transform;
			
			thisObj.layer=LayerManager.LayerShootObject();
			
			if(autoSearchLineRenderer){
				LineRenderer[] lines = thisObj.GetComponentsInChildren<LineRenderer>(true);
				for(int i=0; i<lines.Length; i++) lineList.Add(lines[i]);
			}
			
			TrailRenderer[] trails = thisObj.GetComponentsInChildren<TrailRenderer>(true);
			for(int i=0; i<trails.Length; i++) trailList.Add(trails[i]);
			
			if(type==_ShootObjectType.FPSProjectile){
				SphereCollider sphereCol=GetComponent<SphereCollider>();
				if(sphereCol==null){
					sphereCol=thisObj.AddComponent<SphereCollider>();
					sphereCol.radius=0.15f;
				}
				hitRadius=sphereCol.radius;
			}
			
			if(shootEffect!=null) ObjectPoolManager.New(shootEffect);
			if(hitEffect!=null) ObjectPoolManager.New(hitEffect);
		}
	void Start () {
		shadowRoot = (GameObject)Instantiate(gameObject);
		if (hideShadow)
			shadowRoot.hideFlags = HideFlags.HideInHierarchy;

		shadowRoot.transform.parent = transform.root;

		shadowTable = new Dictionary<Transform, Transform>();

		Destroy(shadowRoot.GetComponent<SkeletonUtilityKinematicShadow>());

		shadowRoot.transform.position = transform.position;
		shadowRoot.transform.rotation = transform.rotation;

		Vector3 scaleRef = transform.TransformPoint(Vector3.right);
		float scale = Vector3.Distance(transform.position, scaleRef);
		shadowRoot.transform.localScale = Vector3.one;

		var shadowJoints = shadowRoot.GetComponentsInChildren<Joint>();
		foreach (Joint j in shadowJoints) {
			j.connectedAnchor *= scale;
		}

		var joints = GetComponentsInChildren<Joint>();
		foreach (var j in joints)
			Destroy(j);

		var rbs = GetComponentsInChildren<Rigidbody>();
		foreach (var rb in rbs)
			Destroy(rb);

		var colliders = GetComponentsInChildren<Collider>();
		foreach (var c in colliders)
			Destroy(c);


		//match by bone name
		var shadowBones = shadowRoot.GetComponentsInChildren<SkeletonUtilityBone>();
		var bones = GetComponentsInChildren<SkeletonUtilityBone>();

		//build bone lookup
		foreach (var b in bones) {
			if (b.gameObject == gameObject)
				continue;

			foreach (var sb in shadowBones) {
				if (sb.rigidbody == null)
					continue;

				if (sb.boneName == b.boneName) {
					shadowTable.Add(sb.transform, b.transform);
					break;
				}
			}
		}

		foreach (var b in shadowBones)
			Destroy(b);
	}
Example #11
0
 void Start()
 {
     hinweis = GameObject.Find ("Hinweis");
     hinweisText = hinweis.GetComponentsInChildren<Text> ();
     hinweisBild = hinweis.GetComponentsInChildren<Image> ();
     showHinweis(false, "");
     showtime = 0;
 }
Example #12
0
 private void SetEnabledForGameObject(GameObject go, bool enabled)
 {
     go.GetComponent<Movement>().enabled = enabled;
     go.GetComponent<PlayerController>().enabled = enabled;
     go.GetComponent<Rigidbody>().useGravity = enabled;
     go.GetComponentsInChildren<MeshRenderer>().SetEnabled(enabled);
     go.GetComponentsInChildren<Collider>().SetEnabled(enabled);
 }
        // InputManagerSetup
        internal static void InputRegister( GameObject gameObject )
        {
            controllers = gameObject.GetComponentsInChildren<ControllerBase>();
            controllersCount = controllers.Length;

            buttons = gameObject.GetComponentsInChildren<ButtonBase>();
            buttonsCount = buttons.Length;
        }
Example #14
0
 private void GridSetUp(GameObject gridObject, GameObject spriteObject)
 {
     for (int i = 0; i < gridObject.GetComponentsInChildren<Image>().Length; i++) {
         if (gridObject.GetComponentsInChildren<Image>()[i].tag == "Sprite") {
             gridObject.GetComponentsInChildren<Image>()[i].sprite = spriteObject.GetComponent<Image>().sprite;
         }
     }
 }
		void Start () {
			// Duplicate this gameObject as the "shadow" with a different parent.
			shadowRoot = Instantiate<GameObject>(this.gameObject);
			Destroy(shadowRoot.GetComponent<SkeletonUtilityKinematicShadow>());

			// Prepare shadow gameObject's properties.
			var shadowRootTransform = shadowRoot.transform;
			shadowRootTransform.position = transform.position;
			shadowRootTransform.rotation = transform.rotation;

			Vector3 scaleRef = transform.TransformPoint(Vector3.right);
			float scale = Vector3.Distance(transform.position, scaleRef);
			shadowRootTransform.localScale = Vector3.one;

			if (!detachedShadow) {
				// Do not change to null coalescing operator (??). Unity overloads null checks for UnityEngine.Objects but not the ?? operator.
				if (parent == null)
					shadowRootTransform.parent = transform.root;  
				else
					shadowRootTransform.parent = parent;
			}

			if (hideShadow)
				shadowRoot.hideFlags = HideFlags.HideInHierarchy;
			
			var shadowJoints = shadowRoot.GetComponentsInChildren<Joint>();
			foreach (Joint j in shadowJoints)
				j.connectedAnchor *= scale;

			// Build list of bone pairs (matches shadow transforms with bone transforms)
			var bones = GetComponentsInChildren<SkeletonUtilityBone>();
			var shadowBones = shadowRoot.GetComponentsInChildren<SkeletonUtilityBone>();
			foreach (var b in bones) {
				if (b.gameObject == this.gameObject)
					continue;
				
				foreach (var sb in shadowBones) {
					if (sb.GetComponent<Rigidbody>() != null && sb.boneName == b.boneName) {
						shadowTable.Add(new TransformPair {
							dest = b.transform,
							src = sb.transform
						});
						break;
					}
				}

			}

			// Destroy conflicting and unneeded components
			DestroyComponents(shadowBones);

			DestroyComponents(GetComponentsInChildren<Joint>());
			DestroyComponents(GetComponentsInChildren<Rigidbody>());
			DestroyComponents(GetComponentsInChildren<Collider>());
		}
    /// <summary>
    /// 将制定GameObject存在的UITexture和UISprite去色,变灰
    /// </summary>
    /// <param name="targetObj"> 目标物体</param>
    /// <param name="gray"> 是否变灰</param>
    /// <param name="atlasName"> 制定图集</param>
    public void ChangeObjectsToGray(GameObject targetObj, bool gray, AtlasName atlasName = AtlasName.EM_AtlasName_None)
    {
        UISprite[] sprites = targetObj.GetComponentsInChildren<UISprite>();
        UITexture[] textures = targetObj.GetComponentsInChildren<UITexture>();

        for (int i = 0; i < sprites.Length; i++)
            ChangeUISpriteToGray(sprites[i], gray, atlasName);

        for (int i = 0; i < textures.Length; i++)
            ChangeUITextureToGary(textures[i], gray);
    }
		public ParticleCacheData(GameObject _particleSystemGameObject)
		{
			//Cache variables
			instantiatedGameObject 	=	_particleSystemGameObject;
			cachedTransform			= 	instantiatedGameObject.transform;
			cachedParticleSystem	= 	instantiatedGameObject.GetComponentsInChildren<ParticleSystem>();
			burstQuantity			= 	instantiatedGameObject.GetComponentsInChildren<ParticleBurstQuantity>();
			
			if (cachedParticleSystem.Length != burstQuantity.Length)
				Debug.LogWarning("You have forgot to add the ParticleBurstQuantity sript on the particleSystem: " + _particleSystemGameObject.name +" you should only use Emit");
		}
 void FadeTexts(GameObject panel, float alphaTarget, float time = 0.5f)
 {
     Text[] array = panel.GetComponentsInChildren<Text>();
     for (int i = 0; i < array.Length; i++) {
         array[i].CrossFadeAlpha(alphaTarget, time, false);
     }
     Button[] arrayButton = panel.GetComponentsInChildren<Button>();
     for (int i = 0; i < arrayButton.Length; i++) {
         if (alphaTarget == 0) arrayButton[i].interactable = false;
         else arrayButton[i].interactable = true;
     }
 }
Example #19
0
    public void FadeChoice(GameObject choice)
    {
        // Choice1.SetActive(false);
        Image[] imgs = choice.GetComponentsInChildren<Image>();
        Text[] texts = choice.GetComponentsInChildren<Text>();

        dealChoice = choice;
        foreach(Image img in imgs )
            img.DOFade(0, 1f).OnComplete( CloseChoice );
        foreach(Text text in texts )
            text.DOFade(0, 1f);
    }
    void window_onShowWindow(bool isShow, bool isStart)
    {
        if (isShow)
        {
            if (dummy == null)
            {
                GameObject pageDown = ControlView.Instance.m_currentPageDown;
                if (pageDown == null) return;

                WRPageQuestionDown qDown = pageDown.GetComponent<WRPageQuestionDown>();
                target = qDown.m_defaultUI.gameObject;

                dummy = GameObject.Instantiate(target) as GameObject;
                dummy.transform.parent = transform;
                dummy.transform.localPosition = target.transform.localPosition;
                dummy.transform.localScale = target.transform.localScale;


                // 팝업 위에오도록 depth 조절
                UIPanel[] panels = dummy.GetComponentsInChildren<UIPanel>();
                for (int i = 0; i < panels.Length; i++)
                {
                    panels[i].depth = 80;
                }

                GameObject pageUp = ControlView.Instance.m_currentPageUp;
                if (pageUp == null) return;

                //ControlQuestionPage qUp = pageUp.GetComponent<ControlQuestionPage>();

                // 정답인 collider 제거 
                InitToggle[] collider = dummy.GetComponentsInChildren<InitToggle>();
                for (int i = collider.Length - 1; i >= 0; i--)
                {
                    Destroy(collider[i]);
                    Destroy(collider[i].GetComponent<UIToggle>());
                    Destroy(collider[i].GetComponent<BoxCollider>());
                }
            }
        }
        else if (!isShow && !isStart)
        {
            if (dummy != null)
            {
                Destroy(dummy);
            }

        }
    }
	IEnumerator Respwan(GameObject player, GameObject spawn) {
		player.GetComponent<BoxCollider> ().enabled = false;
		player.GetComponent<Controls> ().enabled = false;
		player.GetComponent<PhisicalObject> ().enabled = false;

		foreach (Light l in player.GetComponentsInChildren<Light> ()) {
			l.enabled = false;
		}

		foreach (PlayerParticle p in player.GetComponentsInChildren<PlayerParticle>()) {
			p.GetComponentInChildren<Light>().enabled = true;
			p.scatter();
		}

		for (float f = 1f; f >= 0.1; f -= 0.05f) {
			yield return null;
		}


		Vector3 oldPosition = player.transform.position;
		player.transform.position = spawn.transform.position;

		foreach (Light l in player.GetComponentsInChildren<Light> ()) {
			l.enabled = true;
		}

		foreach (PlayerParticle p in player.GetComponentsInChildren<PlayerParticle>()) {		
			p.transform.position = p.transform.position + (oldPosition - player.transform.position);
			p.startReform();
		}

		for (float f = 0f; f <= 1; f += 0.05f) {
			foreach (PlayerParticle p in player.GetComponentsInChildren<PlayerParticle>()) {
				p.ReformLerp(f);
			}
			yield return null;
		}

		foreach (PlayerParticle p in player.GetComponentsInChildren<PlayerParticle>()) {
			p.ReformLerp(1);
		}

		player.GetComponent<PhisicalObject> ().enabled = true;
		player.GetComponent<BoxCollider> ().enabled = true;
		player.GetComponent<Controls> ().enabled = true;
		foreach (PlayerParticle p in player.GetComponentsInChildren<PlayerParticle>()) {		
			p.GetComponentInChildren<Light>().enabled = false;
		}
	}
Example #22
0
	/// <summary>
	/// Clean up the incoming model if there's a bunk transform
	/// </summary>
	/// <param name="go">
	/// A <see cref="GameObject"/>
	/// </param>
	void OnPostprocessModel(GameObject go)
	{
		Component[] skins = go.GetComponentsInChildren<SkinnedMeshRenderer>();
		Component[] transforms = go.GetComponentsInChildren<Transform>();
		
		// check for an empty transform corresponding to each skinned mesh name and remove it
		foreach (SkinnedMeshRenderer skin in skins)
		{
			string name = skin.sharedMesh.name;
			Transform candidate = TransformHelpers.GetTransformInHierarchy(transforms, name);
			if (candidate == null) continue;
			if (candidate.GetComponent<SkinnedMeshRenderer>() != null) continue;
			GameObject.DestroyImmediate(candidate.gameObject, true);
		}
	}
Example #23
0
    public void DisableButtons(GameObject go)
    {
        foreach (Button b in go.GetComponentsInChildren<Button>())
        {
            b.enabled = false;
        }

        foreach (Text t in go.GetComponentsInChildren<Text>())
        {
            foreach (Button b in t.GetComponentsInChildren<Button>())
            {
                b.enabled = true;
            }
        }
    }
Example #24
0
 public void EnableButtons(GameObject go)
 {
     foreach(Button b in go.GetComponentsInChildren<Button>() )
     {
         b.enabled = true;
     }
     foreach (Text t in go.GetComponentsInChildren<Text>())
     {
         Debug.Log(t.name);
         foreach (Button b in t.GetComponentsInChildren<Button>())
         {
             b.enabled = true;
         }
     }
 }
		void SetTag(GameObject parent)
		{
			if (parent == null)
			{
				return;
			}

            if (string.IsNullOrEmpty(filterByComponent.Value)) // do all children
            {
                foreach (Transform child in parent.transform)
                {
                    child.gameObject.tag = tag.Value;
                }
            }
            else
            {
                UpdateComponentFilter();

                if (componentFilter != null) // filter by component
                {
                    var root = parent.GetComponentsInChildren(componentFilter);
                    foreach (var child in root)
                    {
                        child.gameObject.tag = tag.Value;
                    }
                }
            }

			Finish();
		}
Example #26
0
	static void OnSetState(GameObject gameObject, byte prevState, byte currState)
	{
		switch (currState)
		{
			case 0:	// Begin fire.
				{
					//gameObject.GetComponent<Collider>().enabled = true;
					ParticleSystem[] particleSystems = gameObject.GetComponentsInChildren<ParticleSystem>();
					foreach (ParticleSystem particleSystem in particleSystems)
						particleSystem.Play();

					gameObject.GetComponent<CFireHazard>().burning_internal = true;
					gameObject.GetComponent<CActorAtmosphericConsumer>().SetAtmosphereConsumption(true);
				}
				break;

			case 2:	// End fire.
				{
					//gameObject.GetComponent<Collider>().enabled = false;
					ParticleSystem[] particleSystems = gameObject.GetComponentsInChildren<ParticleSystem>();
					foreach (ParticleSystem particleSystem in particleSystems)
						particleSystem.Stop();

					gameObject.GetComponent<CFireHazard>().burning_internal = false;
					gameObject.GetComponent<CActorAtmosphericConsumer>().SetAtmosphereConsumption(false);
				}
				break;
		}
	}
Example #27
0
    public void OnClick(float distance = Mathf.Infinity)
    {
        if (distance > availableDistance)
            return;

        m_itemInfoPanel = GameObject.FindGameObjectWithTag("viewable item info");
        if (m_itemInfoPanel == null)
        {
            _CreateItemInfoPanel();
        }

        m_itemInfoPanel.transform.position = Vector3.zero;
        CanvasGroup canvasGroup = m_itemInfoPanel.GetComponent<CanvasGroup>();
        Text[] texts = m_itemInfoPanel.GetComponentsInChildren<Text>();
        texts[0].text = m_itemInfo.name;
        texts[1].text = m_itemInfo.info;

        Sequence seq = DOTween.Sequence();
        seq.Append(m_itemInfoPanel.transform.GetChild(0).DOScale(1, 0.2f))
            .Join(canvasGroup.DOFade(1, 0.2f))
            .AppendCallback(delegate
            {
                canvasGroup.interactable = true;
            });
    }
Example #28
0
    void SetSlot(GameObject slotObject, ShipComponentDatablock target, bool setBackgroundtexture = true)
    {
        var itemSlot = slotObject.GetComponent<UIItemSlot>();
        if (target == null)
        {
            if (itemSlot == null) return;

            itemSlot.Assign(container.SlotEmptyTexture);
            return;
        }

        PlayMakerFSM.FindFsmOnGameObject(slotObject, "FSM").FsmVariables.FindFsmObject("ComponentObject").Value = target;
        var slotImages = slotObject.GetComponentsInChildren<Image>();
        slotImages[1].sprite = Sprite.Create(target.Icon, new Rect(0, 0, target.Icon.width, target.Icon.height), new Vector2(0.5f, 0.5f));
        slotImages[1].color = Color.white;
        if(setBackgroundtexture) slotImages[0].sprite = container.SlotFilledTexture;
        slotImages[0].color = Color.white;

        if (itemSlot == null) return;

        itemSlot.hoverNormalColor = Color.white;
        itemSlot.hoverHighlightColor = container.SlotFilledHoverColor;
        itemSlot.SetIcon(container.SlotFilledTexture);
        itemSlot.hoverTargetGraphic.color = Color.white;
        itemSlot.OnPointerExit(null);
    }
	// Returns true if the given game object is part of a Robot
	private bool IsRobot(GameObject gObject){
		if (gObject.tag.Equals("Circle")){
			return false;
		}

		if (gObject.tag.Equals("Robot")){
			return true;
		}
		else {
			
			foreach (Transform childTrans in gObject.GetComponentsInChildren<Transform>()){
				if (childTrans.gameObject.tag.Equals("Robot")){
					return true;
				}
			}

			foreach (Transform parentTrans in gObject.GetComponentsInParent<Transform>()){
				if (parentTrans.gameObject.tag.Equals("Robot")){
					return true;
				}
			}

		}

		return false;
	}
Example #30
0
    //Should be its own Class!
    public void GenerateCloud()
    {
        //Creates Cloud GameObject
        GameObject cloud =  new GameObject();
        cloud.transform.position = new Vector3(0,0,0);
        cloud.name = "Cloud";

        //Create Platforms
        platformGen.GeneratePlatforms(grid,cloud);

        //Add Plants
        collectibleGen.GenerateCollectibles (grid, cloud);

        //Shift Cloud
        Vector3 bottomLeft = Camera.main.ScreenToWorldPoint (new Vector3 (0f, 0f, 0f));
        Vector3 topRight = Camera.main.ScreenToWorldPoint (new Vector3 (Camera.main.pixelWidth, Camera.main.pixelHeight, 0f));
        bottomLeft.y = Camera.main.GetComponent<FixedHeight> ().height - (topRight.y - bottomLeft.y)/2f;
        cloud.transform.position = new Vector3(topRight.x,bottomLeft.y, cloud.transform.position.z);
        cloud.AddComponent<Cloud>();

        Transform[] children = cloud.GetComponentsInChildren<Transform>();
        float tempx = 0f;
        for(int i = 0; i < children.Length; i++)
        {
            if(children[i].position.x > tempx)
            {
                cloud.GetComponent<Cloud>().farthestPlatform = children[i].gameObject;
                tempx = children[i].position.x;

            }
        }
        //Debug.Log (children.);
        //cloud.GetComponent<Cloud>().farthestPlatform =
    }