本文整理汇总了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;
}
示例2: ISWeapon
public ISWeapon(int durability, int maxDurability, ISEquipmentSlot equipmentSlot, GameObject prefab)
{
_durability = durability;
_maxDurability = maxDurability;
_equipmentSlot = equipmentSlot;
_prefab = prefab;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例7: DoAddComponent
void DoAddComponent(GameObject go)
{
addedComponent = go.AddComponent(script.Value);
if (addedComponent == null)
ActionHelpers.RuntimeError(this, "Can't add script: " + script.Value);
}
示例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();
}
示例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
}
示例10: Awake
void Awake()
{
player = GameObject.FindGameObjectWithTag ("Player");
pHealth = player.GetComponent<PlayerHealth> ();
eHealth = GetComponent<EnemyHealth> ();
eMove = GetComponent<EnemyMovement> ();
}
示例11: SpawnCloud
void SpawnCloud()
{
if (BoilerLid.lidIsOpen)
{
spawnedCloud = Instantiate(cloudToSpawn, new Vector3(-5.02f, 18.8f, 5.03f), transform.rotation) as GameObject;
}
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
示例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
}