当前位置: 首页>>代码示例>>C#>>正文


C# GameObject.SetActive方法代码示例

本文整理汇总了C#中UnityEngine.GameObject.SetActive方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.SetActive方法的具体用法?C# GameObject.SetActive怎么用?C# GameObject.SetActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.GameObject的用法示例。


在下文中一共展示了GameObject.SetActive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Char_Con

    public static IEnumerator Char_Con(GameObject obj) {
        Debug.Log("delete");

        obj.SetActive(false);
        yield return new WaitForSeconds(watetime);
        obj.SetActive(true);
    }
开发者ID:K-U-,项目名称:ggjtut7,代码行数:7,代码来源:ArrowEvent.cs

示例2: PauseGame

    void PauseGame(bool isPaused, GameObject pausemenu)
    {
        isPaused = !isPaused;

        if (isPaused)
        {

            Cursor.lockState = CursorLockMode.None;
            Cursor.visible = true;
            Time.timeScale = 0;
            pausemenu.SetActive(isPaused);
            glock.enabled = false;
            gunShot.enabled = false;
        }
        else
        {

            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible = false;
            Time.timeScale = 1;
            pausemenu.SetActive(isPaused);
            glock.enabled = true;
            gunShot.enabled =true;
        }
    }
开发者ID:selu285-2015,项目名称:285_02_FA15G2,代码行数:25,代码来源:PauseMenu.cs

示例3: Start

	// Use this for initialization
	void Start () {
		PlayerProfile.profile.load();
		uploadedPhotoScreen = GameObject.FindGameObjectWithTag ("postedscreen");
		uploadQueueScreen = GameObject.Find ("PanelUploads");
		photoPanel = GameObject.FindGameObjectWithTag ("photopanel");
		blogNameText = GameObject.FindGameObjectWithTag ("blogname").GetComponent<Text>();
		namePrompt = GameObject.FindGameObjectWithTag ("blogprompt");
		nameChangeScreen = GameObject.FindGameObjectWithTag ("changenamescreen");
		name_field = namePrompt.GetComponentInChildren<InputField> ();
		seenSecondScreen = PlayerProfile.profile.blogNameChangeTipSeen;
		blogSource = GetComponent<AudioSource> ();
		scrollBarPostedPhotos = GameObject.Find ("ScrollViewPostedPhotos").GetComponentInChildren<Scrollbar> ();
		postedPhotosSR = GameObject.Find ("ScrollViewPostedPhotos").GetComponentInChildren<ScrollRect> ();
		postedPhotosSR.movementType = ScrollRect.MovementType.Clamped;
		scrollBarPostedPhotos.value = 1f;

		if (!PlayerProfile.profile.blogNamed) {
			namePrompt.SetActive(true);
			nameChangeScreen.SetActive (false);
		} else {
			namePrompt.SetActive (false);
			nameChangeScreen.SetActive (false);
		}

		photoPanel.SetActive (false);
		blogSource.ignoreListenerPause = true;
		blogSource.Play();

		pathToPostedPhotos = Application.dataPath + "/Resources/PostedImages/";
		pathToUploadQueue = Application.dataPath + "/Resources/UploadQueue/";

		if (nothingToUpload ()) {
			uploadQueueScreen.SetActive (false);
		}
	}
开发者ID:SamReha,项目名称:SnapshotGame,代码行数:36,代码来源:BlogUIManager.cs

示例4: ToggleActive

 // Toggle UI panels between active and inactive
 public void ToggleActive(GameObject obj)
 {
     Debug.Log("ToggleActive: " + obj.name);
     if (!obj.activeSelf)
     {
         obj.SetActive(true);
         _activePanels++;
         if (!_UIActive)
         {
             ToggleUIMode();
         }
     }
     else if (obj.activeSelf)
     {
         if (obj == _UIPanels[1])
         {
             ClearPanel(_UIPanels[1].transform.FindChild(ITEM_PANEL));
         }
         obj.SetActive(false);
         _activePanels--;
         if (_UIActive && _activePanels <= 0)
         {
             ToggleUIMode();
         }
     }
 }
开发者ID:BeauArthurs,项目名称:KingdomOfMadness,代码行数:27,代码来源:Tools.cs

示例5: startPageActions

        IEnumerator startPageActions(GameObject instructionText, float initialDelay, onStartPageActionsCompleteCB onStartPageActionsComplete)
        {
            m_gestureSphere.transform.position = new Vector3(0.0f + m_pageScale.x / 3, 0.0f, kSphereZPos);
            Vector3 moveToPos = new Vector3((0.0f - m_pageScale.x / 3) / transform.localScale.x, 0.0f, kSphereZPos);
            Vector3 originalTextScale = instructionText.transform.localScale;

            yield return StartCoroutine(Actions.Wait(initialDelay));

            // Instruction text actions
            instructionText.transform.localScale = Vector3.zero;
            instructionText.SetActive(true);
            StartCoroutine(instructionText.transform.ScaleTo(originalTextScale, 0.75f, EaseType.CubeOut));
            yield return StartCoroutine(Actions.Wait(1.0f));

            // Sphere Actions
            m_gestureSphere.SetActive(true);

            StartCoroutine(m_gestureSphere.transform.ScaleTo(new Vector3(1.0f / transform.localScale.x, 1.0f / transform.localScale.y, 1.0f / transform.localScale.z), 0.75f, EaseType.BackOut));
            yield return StartCoroutine(Actions.Wait(1.25f));
            StartCoroutine(m_gestureSphere.transform.MoveTo(moveToPos, 1.5f, EaseType.SineInOut));
            yield return StartCoroutine(Actions.Wait(2.75f));
            StartCoroutine(m_gestureSphere.transform.ScaleTo(Vector3.zero, 0.75f, EaseType.CubeIn));
            StartCoroutine(instructionText.transform.ScaleTo(Vector3.zero, 0.75f, EaseType.CubeIn));
            yield return StartCoroutine(Actions.Wait(0.75f));

            m_gestureSphere.SetActive(false);
            instructionText.SetActive(false);
            instructionText.transform.localScale = originalTextScale;

            onStartPageActionsComplete();

            yield return 0;
        }
开发者ID:JoshElden,项目名称:MobileInputDemo,代码行数:33,代码来源:StartPageActions.cs

示例6: Start

    IEnumerator Start()
    {
        // Titleゲームオブジェクトを検索し取得する
        title = GameObject.Find ("Title");

        while (true) {
            //タイトルを表示し、xキーが押されるまで待機する
            title.SetActive (true);
            while (Input.GetKeyDown (KeyCode.X) == false) {
                yield return null;
            }

            // ゲームスタート時に、タイトルを非表示にしてプレイヤーを作成する
            title.SetActive (false);
            IsPlaying = true;
            Instantiate (player, player.transform.position, player.transform.rotation);

            // ゲームオーバーになるまで待機する
            while (IsPlaying == true) {
                yield return null;
            }

            // ゲームオーバー時データを保存する
            FindObjectOfType<Score> ().Save ();
        }
    }
开发者ID:tsubaki,项目名称:ShootingGame,代码行数:26,代码来源:Manager.cs

示例7: EditorModel

        public EditorModel(GameObject assetPrefab)
        {
            prefab = assetPrefab;

            saveAssetFolder = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(prefab));

            assetInstance = GameObject.Instantiate(assetPrefab) as GameObject;
            assetInstance.name = assetPrefab.name;
            assetInstance.SetActive(true);

            // Check for LocalSettings on the prefab and use that if possible
            LocalSettings = assetInstance.GetComponentInChildren<LocalSettings>();
            if (LocalSettings != null) {
            UseLocalSettings = true;
            BlobModel = assetInstance.AddComponent<ABlobModel>().InitWithExistingBlob(LocalSettings.gameObject);
            } else {
            Mesh blobMesh = AssetDatabase.LoadAssetAtPath("Assets/BlobOMatic/BlobMesh.asset", typeof(Mesh)) as Mesh;
            BlobModel = assetInstance.AddComponent<ABlobModel>().Init(blobMesh);
            if (!ICanHasShadow) return; // Not a valid model, bugger off!

            LocalSettings = BlobModel.BlobRenderer.gameObject.AddComponent<LocalSettings>().CopyGlobalSettings();

            saveAssetFolder +=  "/" + prefab.name + "WithBlob";
            }

            // Collect original layers and set everything to blob layer
            foreach (Transform t in assetInstance.GetComponentsInChildren<Transform>(true))
            originalLayers[t.gameObject] = t.gameObject.layer;
            assetInstance.SetLayerRecursively(BlobOMatic.EditorLayer);

            assetInstance.SetActive(false);
            assetInstance.SetHideFlagsRecursively(HideFlags.HideAndDontSave);

            RenderBlob();
        }
开发者ID:shadercoder,项目名称:Unity3D-experiments,代码行数:35,代码来源:EditorModel.cs

示例8: LoadGameObject

    public void LoadGameObject(string name)
    {
        specialPrefab = (GameObject)Resources.Load("Prefabs/" + name);
        specialInstance = (GameObject)Instantiate(specialPrefab);
        specialInstance.transform.parent = gameObject.transform.parent;

        switch (playerInfo.charEnum)
        {
            case CharacterEnum.Tesla:
                specialInstance.GetComponent<WeaponSpecialTeslaLogic>().SetUpVariables(playerBase, bulletManager, weaponBase);
                specialInstance.SetActive(false);
                break;
            case CharacterEnum.Curie:
                specialInstance.GetComponent<WeaponSpecialCurieLogic>().SetUpVariables(playerBase, bulletManager);
                specialInstance.SetActive(false);
                break;
            case CharacterEnum.DaVinci:
                specialInstance.GetComponent<WeaponSpecialDaVinciLogic>().SetUpVariables(playerBase, bulletManager, weaponBase);
                //specialInstance.GetComponent<WeaponSpecialTeslaLogic>().SetUpVariables(playerBase, bulletManager, weaponBase);
                break;
            case CharacterEnum.Einstein:
                specialInstance.GetComponent<WeaponSpecialEinsteinLogic>().SetUpVariables(playerBase, bulletManager);
                specialInstance.SetActive(false);
                break;
            case CharacterEnum.Nobel:
                specialInstance.GetComponent<WeaponSpecialNobelLogic>().SetUpVariables(playerBase, bulletManager, weaponBase);
                break;
        }
    }
开发者ID:ja003,项目名称:PV255-Brainiacs,代码行数:29,代码来源:WeaponSpecial.cs

示例9: SetActiveAnimated

        /// <summary>
        /// Set the active state and trigger animation update.
        /// </summary>
        /// <param name="gameObject"></param>
        /// <param name="value"></param>
        public static IEnumerator SetActiveAnimated(GameObject gameObject, bool value)
        {
            Animator animator = gameObject.GetComponent<Animator>();

            if (value)
            {
                gameObject.SetActive(true);
                animator.Play("NotActive");
                animator.SetBool("Active", true);
            }
            else
            {
                animator.SetBool("Active", false);
                bool closedStateReached = false;
                while (!closedStateReached)
                {
                    if (!animator.IsInTransition(0))
                        closedStateReached = animator.GetCurrentAnimatorStateInfo(0).IsName("NotActive");

                    yield return new WaitForEndOfFrame();
                }

                gameObject.SetActive(false);
            }
        }
开发者ID:DanFlannel,项目名称:Pokemon_Battle_Simulator,代码行数:30,代码来源:DisplayItemHelper.cs

示例10: ClickSetBtn

    public void ClickSetBtn(GameObject btn,GameObject panel)
    {
        if (isSetShow)
        {
            iTween.MoveTo(btn, iTween.Hash
                   (
                       "position", oldPos,
                       "time", 0.5f,
                       "islocal", true
                   )
               );
            isSetShow = false;
            panel.SetActive(false);

        }
        else
        {
            iTween.MoveTo(btn, iTween.Hash
                   (
                       "position", newPos,
                       "time", 0.5f,
                       "islocal", true
                   )
               );
            isSetShow = true;
            panel.SetActive(true);

        }

    }
开发者ID:daluanren,项目名称:CandyCrushGame,代码行数:30,代码来源:StartPageController.cs

示例11: Respawn

 IEnumerator Respawn(float delay, GameObject obj)
 {
     obj.SetActive (false);
     yield return new WaitForSeconds (delay);
     obj.SetActive (true);
     Debug.Log ("I live again!");
 }
开发者ID:Crazydriver8,项目名称:Ghosts,代码行数:7,代码来源:GameController.cs

示例12: multiTouchPageActions

        IEnumerator multiTouchPageActions(GameObject instructionText, float initialDelay)
        {
            Vector3 originalTextScale = instructionText.transform.localScale;
            Vector3 originalTouchCountScale = m_touchesLbl.transform.localScale;
            yield return StartCoroutine(Actions.Wait(initialDelay));

            // Instruction text actions
            instructionText.transform.localScale = Vector3.zero;
            instructionText.SetActive(true);
            StartCoroutine(instructionText.transform.ScaleTo(originalTextScale, 0.75f, EaseType.CubeOut));

            m_touchesLbl.transform.localScale = Vector3.zero;
            m_touchesLbl.SetActive(true);

            yield return StartCoroutine(Actions.Wait(0.75f));
            m_gesturesEnabled = true;
            StartCoroutine(m_touchesLbl.transform.ScaleTo(originalTextScale, 0.75f, EaseType.CubeOut));
            yield return StartCoroutine(Actions.Wait(3.0f));


            StartCoroutine(instructionText.transform.ScaleTo(Vector3.zero, 0.75f, EaseType.CubeIn));
            yield return StartCoroutine(Actions.Wait(0.75f));

            instructionText.SetActive(false);
            instructionText.transform.localScale = originalTextScale;           

            yield return 0;
        }
开发者ID:JoshElden,项目名称:MobileInputDemo,代码行数:28,代码来源:MultiTouchPageActions.cs

示例13: ImageCoroutine

    IEnumerator ImageCoroutine(GameObject image, float delta, int destination, bool active)
    {
        if (actionLocked) { yield break; }
        else { actionLocked = true; }

        image.SetActive(true);
        Color color = image.GetComponent<Image>().color;
        while (true)
        {
            if ((delta < 0 && image.GetComponent<Image>().color.a <= destination) ||
                (delta > 0 && image.GetComponent<Image>().color.a >= destination))
                break;

            color.a += delta;
            image.GetComponent<Image>().color = color;

            color = image.GetComponent<Image>().color;
            yield return null;
        }
        color.a = destination;
        image.GetComponent<Image>().color = color;
        image.SetActive(active);

        actionLocked = false;
        yield break;
    }
开发者ID:yjao,项目名称:EvasiveManeuvers,代码行数:26,代码来源:MainMenu.cs

示例14: PopEffect

	private IEnumerator PopEffect(GameObject _obj) {
		_obj.SetActive(true);
		_obj.transform.localScale = Vector2.zero;

		Image img = _obj.GetComponent<Image>();
//		Text text = _obj.transform.Find("Text").GetComponent<Text>();

		float ft = 0.0f;
		float fV = 0.0f;
		float _time = 0.15f;

		Color orgImgColor = img.color;
//		Color orgTextColor = text.color;

		do
		{
			ft = Mathf.SmoothDamp(ft, 1.0f, ref fV, _time); // 0 ~ 1
			_obj.transform.localScale = Vector2.Lerp(Vector2.zero, Vector2.one, ft);

			Color color = Color.Lerp(Color.clear, orgImgColor, ft);

			img.color = color;
//			text.color = color;
            yield return null;
		} while (ft < 0.95f);

		img.color = orgImgColor;
//		text.color = orgTextColor;
		yield return new WaitForSeconds(0.3f);
        _obj.SetActive(false);
	}
开发者ID:GooKu,项目名称:GGJ2016_Jyeeeee,代码行数:31,代码来源:NoticeView.cs

示例15: get_menu

 public void get_menu(GameObject g)
 {
     if (g.activeSelf)
         g.SetActive (false);
     else
         g.SetActive (true);
 }
开发者ID:gogolB,项目名称:NuGame,代码行数:7,代码来源:Center_submenu.cs


注:本文中的UnityEngine.GameObject.SetActive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。