當前位置: 首頁>>代碼示例>>C#>>正文


C# UnityEngine.GameObject類代碼示例

本文整理匯總了C#中UnityEngine.GameObject的典型用法代碼示例。如果您正苦於以下問題:C# GameObject類的具體用法?C# GameObject怎麽用?C# GameObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GameObject類屬於UnityEngine命名空間,在下文中一共展示了GameObject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: hide

 void hide(GameObject bt)
 {
     messageBox.gameObject.SetActive(false);
     blurPanel.gameObject.SetActive(false);
     info.show = false;
     isShow = false;
 }
開發者ID:zhendery,項目名稱:FiveVsFive,代碼行數:7,代碼來源:MessageBox.cs

示例2: ISWeapon

 public ISWeapon(int durability, int maxDurability, ISEquipmentSlot equipmentSlot, GameObject prefab)
 {
     _durability = durability;
     _maxDurability = maxDurability;
     _equipmentSlot = equipmentSlot;
     _prefab = prefab;
 }
開發者ID:zachstratton,項目名稱:ItemSytem,代碼行數:7,代碼來源:ISWeapon.cs

示例3: SubmitLap

        public void SubmitLap(GameObject car, int team)
        {
            switch (team)
            {
                case 1:
                    if (m_LapTimeTeamOne >= 60.0f)
                    {
                        m_LapsTeamOne += 1;
                        m_LapTimeTeamOne = 0.0f;
                    }
                    break;

                case 2:
                    if (m_LapTimeTeamTwo >= 60.0f)
                    {
                        m_LapsTeamTwo += 1;
                        m_LapTimeTeamTwo = 0.0f;
                    }
                    break;
            }

            if (m_LapsTeamOne >= 2)
            {
                instance.SubmitGameResults(m_TeamOneWon);
            }
            if (m_LapsTeamTwo >= 2)
            {
                instance.SubmitGameResults(m_TeamTwoWon);
            }
        }
開發者ID:stijndelaruelle,項目名稱:glupartygame,代碼行數:30,代碼來源:GameController.cs

示例4: PlayState2

				//private PlayerScript controller;
		
				public PlayState2 (StateManager managerRef)
				{ //Constructor
						manager = managerRef;
						Debug.Log ("Constructing PlayState2");
						manager.darkState = false; 
			
						"Stage2".LoadScene ();
						//if (Application.loadedLevelName != "Stage2")
						//		Application.LoadLevel ("Stage2");
			
						StaticMethods.SetOneActive ("Following Camera", manager.gameDataRef.cameras); //Camera that follows the Player, setOneActive method

						player = GameObject.FindGameObjectWithTag ("Player"); //the Player GameObject is now active and can be found
						player.GetComponent<Rigidbody2D> ().isKinematic = false; //Player is now affected by physics
			
						player.transform.SetPositionXY (-6.0f, -0.4f); //set starting position for Player
						skin = Resources.Load ("GUISkin") as GUISkin;
				
						//darkness = GameObject.FindGameObjectWithTag ("Darkness");
						//dark.a += 0f;
						//darkness.GetComponent<Renderer>().material.color = dark; 
			
						//darkness.GetComponent<Renderer>().material.color.a;
						//Color dark = darkness.renderer.material.color;
						//dark.a -= 0;
						//darkness.renderer.material.color = color;
				}
開發者ID:katerinakat,項目名稱:Platform_Game,代碼行數:29,代碼來源:PlayState2.cs

示例5: UpdateTime

        public override void UpdateTime(GameObject Actor, float runningTime, float deltaTime)
        {
            Animation animation = Actor.GetComponent<Animation>();

            if (!animation || animationClip == null)
            {
                return;
            }

            if (animation[animationClip.name] == null)
            {
                animation.AddClip(animationClip, animationClip.name);
            }

            AnimationState state = animation[animationClip.name];

            if (!animation.IsPlaying(animationClip.name))
            {
                animation.wrapMode = wrapMode;
                animation.Play(animationClip.name);
            }

            state.time = runningTime;
            state.enabled = true;
            animation.Sample();
            state.enabled = false;
        }
開發者ID:EJ10,項目名稱:CinemaActionProjectTest,代碼行數:27,代碼來源:PlayAnimationEvent.cs

示例6: CreatePulse

 public static void CreatePulse(MenuCommand menuCommand)
 {
     var pulse = new GameObject("Pulse", typeof(Pulse));
     GameObjectUtility.SetParentAndAlign(pulse, menuCommand.context as GameObject);
     Undo.RegisterCreatedObjectUndo(pulse, "Create " + pulse.name);
     Selection.activeGameObject = pulse;
 }
開發者ID:CarlosMeloStuff,項目名稱:PulseSequencer,代碼行數:7,代碼來源:PulseEditorHelpers.cs

示例7: DoAddComponent

		void DoAddComponent(GameObject go)
		{
			addedComponent = go.AddComponent(script.Value);

			if (addedComponent == null)
				ActionHelpers.RuntimeError(this, "Can't add script: " + script.Value);
		}
開發者ID:AlexanderUrbano,項目名稱:shapewars,代碼行數:7,代碼來源:AddScript.cs

示例8: SetTag

		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();
		}
開發者ID:ChetahPangestu,項目名稱:MajorProjectReveal,代碼行數:30,代碼來源:SetTagsOnChildren.cs

示例9: GetActive

		public bool GetActive(GameObject go){
			#if UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5	
			return go.active;
			#else
			return go.activeInHierarchy;
			#endif			
		}
開發者ID:watapax,項目名稱:Antartica_AR,代碼行數:7,代碼來源:MB3_MBVersionConcrete.cs

示例10: Awake

 void Awake()
 {
     player = GameObject.FindGameObjectWithTag ("Player");
     pHealth = player.GetComponent<PlayerHealth> ();
     eHealth = GetComponent<EnemyHealth> ();
     eMove = GetComponent<EnemyMovement> ();
 }
開發者ID:ltrout,項目名稱:TankBattle,代碼行數:7,代碼來源:EnemyAttack_Med.cs

示例11: SpawnCloud

 void SpawnCloud()
 {
     if (BoilerLid.lidIsOpen)
     {
         spawnedCloud = Instantiate(cloudToSpawn, new Vector3(-5.02f, 18.8f, 5.03f), transform.rotation) as GameObject;
     }
 }
開發者ID:Dawnwoodgames,項目名稱:LotsOfTowers,代碼行數:7,代碼來源:FireWood.cs

示例12: Start

        void Start()
        {
            container = new GameObject("_ObjectPool");
            if (prefabsToPool == null) return;

            // AUTOPOOL: Find all Destructible objects with DestroyedPrefabs in the scene that have Auto-Pool set to TRUE.
            Destructible[] destructibleObjectsInScene = FindObjectsOfType<Destructible>();
            autoPooledObjects = new Dictionary<int, GameObject>();
            AddDestructibleObjectsToPool(destructibleObjectsInScene);

            // Instantiate game objects from the PrefabsToPool list and add them to the Pool.
            Pool = new GameObject[prefabsToPool.Count][];
            for (int i = 0; i < prefabsToPool.Count; i++)
            {
                PoolEntry poolEntry = prefabsToPool[i];
                Pool[i] = new GameObject[poolEntry.Count];
                for (int n=0; n<poolEntry.Count; n++)
                {
                    if (poolEntry.Prefab == null) continue;
                    var newObj = Instantiate(poolEntry.Prefab);
                    newObj.name = poolEntry.Prefab.name;
                    PoolObject(newObj);
                }
            }
        }
開發者ID:tegleg,項目名稱:mfp,代碼行數:25,代碼來源:ObjectPool.cs

示例13: DoSetFsmGameObject

        void DoSetFsmGameObject()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);
            if (go == null)
            {
                return;
            }

            if (go != goLastFrame)
            {
                goLastFrame = go;

                // only get the fsm component if go has changed

                fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value);
            }

            if (fsm == null)
            {
                return;
            }

            var fsmGameObject = fsm.FsmVariables.GetFsmGameObject(variableName.Value);

            if (fsmGameObject != null)

            {
                fsmGameObject.Value = setValue == null ? null : setValue.Value;
            }
        }
開發者ID:personal-robots,項目名稱:storyspace,代碼行數:30,代碼來源:SetFsmGameObject.cs

示例14: ComputeHull

        public static int ComputeHull(GameObject gameObject, FracturedObject fracturedObject)
        {
            int nTotalTriangles = 0;

            if(ComputeHull(gameObject, fracturedObject.ConcaveColliderAlgorithm, fracturedObject.ConcaveColliderMaxHulls, fracturedObject.ConcaveColliderMaxHullVertices, fracturedObject.ConcaveColliderLegacySteps, fracturedObject.Verbose, out nTotalTriangles) == false)
            {
                if(fracturedObject.ConcaveColliderAlgorithm == FracturedObject.ECCAlgorithm.Fast)
                {
                    // Fast failed. Try with normal.
                    if(fracturedObject.Verbose)
                    {
                        Debug.Log(gameObject.name + ": Falling back to normal convex decomposition algorithm");
                    }

                    if(ComputeHull(gameObject, FracturedObject.ECCAlgorithm.Normal, fracturedObject.ConcaveColliderMaxHulls, fracturedObject.ConcaveColliderMaxHullVertices, fracturedObject.ConcaveColliderLegacySteps, fracturedObject.Verbose, out nTotalTriangles) == false)
                    {
                        if(fracturedObject.Verbose)
                        {
                            Debug.Log(gameObject.name + ": Falling back to box collider");
                        }
                    }
                }
            }

            return nTotalTriangles;
	    }
開發者ID:cxtadment,項目名稱:Mobile-Game---Free-Mind,代碼行數:26,代碼來源:ConcaveColliderInterface.cs

示例15: SetActiveRecursively

		public void SetActiveRecursively(GameObject go, bool isActive){
			#if UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5	
			go.SetActiveRecursively(isActive);
			#else
			go.SetActive(isActive);
			#endif
		}
開發者ID:watapax,項目名稱:Antartica_AR,代碼行數:7,代碼來源:MB3_MBVersionConcrete.cs


注:本文中的UnityEngine.GameObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。