本文整理汇总了C#中GameObject类的典型用法代码示例。如果您正苦于以下问题:C# GameObject类的具体用法?C# GameObject怎么用?C# GameObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GameObject类属于命名空间,在下文中一共展示了GameObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
// Use this for initialization
void Awake ()
{
player = GameObject.FindGameObjectWithTag("Player");
playerControl = player.GetComponent<playerControl>();
som = gameObject.GetComponent<AudioSource>();
bala = gameObject.GetComponent<MeshRenderer>();
}
示例2: OnDrop
void OnDrop (GameObject go)
{
if (onDrop && target != null)
{
target.SendMessage("OnDrop", go, SendMessageOptions.DontRequireReceiver);
}
}
示例3: FindMissingReferences
private static void FindMissingReferences(string context, GameObject[] objects)
{
foreach (var go in objects)
{
var components = go.GetComponents<Component>();
foreach (var c in components)
{
if (!c)
{
Debug.LogError("Missing Component in GO: " + FullPath(go), go);
continue;
}
SerializedObject so = new SerializedObject(c);
var sp = so.GetIterator();
while (sp.NextVisible(true))
{
if (sp.propertyType == SerializedPropertyType.ObjectReference)
{
if (sp.objectReferenceValue == null
&& sp.objectReferenceInstanceIDValue != 0)
{
ShowError(context, go, c.GetType().Name, ObjectNames.NicifyVariableName(sp.name));
}
}
}
}
}
}
示例4: cellClicked
public void cellClicked(GameObject go)
{
MusicManager.playEffectMusic("SFX_UI_button_tap_2a");
// if(selectedCell != go)
// {
selectedCell = go;
SkillTreeCell cell = selectedCell.GetComponent<SkillTreeCell>();
if (SkillLearnedData.LearnedState.LEARNED == cell.learnedData.State)
{
// cell.IsSelected = true;
// cell.updateOutlook();
// changeHeroSkillList(cell);
// changeSkillTreeCellBortherState(cell);
// UserInfo.instance.saveAllheroes();
selectSkill(cell);
}
descDlg.DescIcon.spriteName = cell.icon.spriteName;
descDlg.DescIcon.gameObject.SetActive(true);
descDlg.DescIconBg.spriteName = cell.frame.spriteName;
descDlg.DescIconBg.MakePixelPerfect();
descDlg.DescIconBg.gameObject.SetActive(true);
descDlg.Show(cell.skillDef);
descDlg.SetTrainingBtnVisible(SkillLearnedData.LearnedState.UNLEARNED == cell.learnedData.State);
descDlg.SetSkippingBtnVisible(SkillLearnedData.LearnedState.LEARNING == cell.learnedData.State);
descDlg.skillTrainTimeMask.fillAmount = 0;
cell.OnFinished = OnFinishedLearning;
}
示例5: onPickupClock
public void onPickupClock(GameObject go, bool tr) {
Interactable inter = go.GetComponent<Interactable>();
if(inter != null) {
//TODO Start ticking sound
inter.setPuzzleState("pickedUp");
}
}
示例6: ItWillHaveTheGameObjectSet
public void ItWillHaveTheGameObjectSet()
{
GameObject go = new GameObject();
Component comp = new TestComponent();
go.AddComponent(comp);
Assert.That(comp.gameObject, Is.SameAs(go));
}
示例7: OnMouseDown
public void OnMouseDown()
{
//pego a unidade selecionada atravez do controlador de jogo
GameObject selecionado = gameObject.transform.parent.parent.parent.GetComponent<ControladorDeJogo>().objetoSelecionado;
//Se tiver algum objeto selecionado, mando a unidade selecionada se mover para o objeto clicado
if(selecionado != null)
{//Se tiver alguma unidade selecionada
if(tropaJogador == null)
{//E se nao tiver nem uma unidade nesse alvo (unidade do jogador)
//Defino que tem uma unidade vindo pra ca
tropaJogador = selecionado;
//Se a unidade que esta vindo estiver vindo de um outro alvo, limpo o alvo antigo
if(tropaJogador.GetComponent<ComportamentoDeUnidade>().alvoAtual != null)
tropaJogador.GetComponent<ComportamentoDeUnidade>().alvoAtual.GetComponent<AcoesJogadorAlvo>().tropaJogador = null;
//Mando a unidade se mover para o alvo atual
tropaJogador.GetComponent<ComportamentoDeUnidade>().moverSoldados(gameObject);
//E digo que esse alvo e o novo destino dele
tropaJogador.GetComponent<ComportamentoDeUnidade>().alvoAtual = gameObject;
//atualizar as cores do alvo
atualizarCores();
}
else
gameObject.transform.parent.parent.parent.GetComponent<ControladorDeJogo>().hud.GetComponent<ControladorDeInterface>().escreverMensagem("Nao pode haver dois grupos em um mesmo alvo");
}
}
示例8: Start
void Start()
{
player = GameObject.FindGameObjectWithTag("Player");
anim = GetComponent<Animator>();
charControl = GetComponent<CharacterController>();
}
示例9: updateAllBuildings
public void updateAllBuildings()
{
// Ottengo il numero di costruzioni sulla cella
GameManager gMgr = GameObject.Find("GameManager").GetComponent<GameManager>();
// Ciclo su tutte le mini-celle della board principale
for (int i = 0; i < 40; i++) {
// Ottengo la cella corrente
GameObject curCell = GameObject.FindGameObjectWithTag(i.ToString());
try {
// Ottengo il set di case incluse nella cella
GameObject curSet = curCell.transform.Find("GlobalBuildings").gameObject;
GameObject[] curBuildings = new GameObject[5];
// Nascondo prima tutte le costruzioni
for (int houseIndex = 0; houseIndex < 5; houseIndex++) {
// trovo la componente che ci serve
curBuildings[houseIndex] = curSet.transform.Find("b" + (houseIndex+1).ToString()).gameObject;
curBuildings[houseIndex].SetActiveRecursively(false);
}
int mBuildings = 0;
try {
mBuildings = gMgr.Cells[i].getProperty().getNumberOfBuildings();
} catch (ArgumentOutOfRangeException e) {
mBuildings = 0;
}
if (mBuildings > 0) {
// Aggiorno i valori della cella
setBuildings(mBuildings, curBuildings);
}
} catch (NullReferenceException e) {
}
}
}
示例10: OnCreate
private static void OnCreate(GameObject sender, EventArgs args)
{
if (sender.Name.Contains("healingBuff"))
{
_healingBuffs.Add(sender);
}
}
示例11: serchTag
//指定されたタグの中で最も近いものを取得
GameObject serchTag(GameObject nowObj,string tagName)
{
float tmpDis = 0; //距離用一時変数
float nearDis = 0; //最も近いオブジェクトの距離
//string nearObjName = ""; //オブジェクト名称
GameObject targetObj = null; //オブジェクト
//タグ指定されたオブジェクトを配列で取得する
foreach (GameObject obs in GameObject.FindGameObjectsWithTag(tagName)){
//自身と取得したオブジェクトの距離を取得
tmpDis = Vector3.Distance(obs.transform.position, nowObj.transform.position);
//オブジェクトの距離が近いか、距離0であればオブジェクト名を取得
//一時変数に距離を格納
if (nearDis == 0 || nearDis > tmpDis){
nearDis = tmpDis;
//nearObjName = obs.name;
targetObj = obs;
}
}
//最も近かったオブジェクトを返す
//return GameObject.Find(nearObjName);
return targetObj;
}
示例12: Start
static public GameObject target; // the target that the camera should look at
void Start () {
if (target == null)
{
target = this.gameObject;
Debug.Log ("LookAtTarget target not specified. Defaulting to parent GameObject");
}
}
示例13: LoadResourceInsteadOfAwake
public void LoadResourceInsteadOfAwake()
{
if (m_bLoadResourceInsteadOfAwake)
return;
m_bLoadResourceInsteadOfAwake = true;
m_myTransform = transform;
FillFullNameData(m_myTransform);
m_goFingerTailUIDrawRange = FindTransform("FingerTailUIDrawRange").gameObject;
m_goFingerTailUIDrawPanel = FindTransform("FingerTailUIDrawPanel").gameObject;
DontDestroyOnLoad(m_goFingerTailUIDrawPanel);
ShowFingerTailUIDrawPanel(false);
m_goFingerTailUIDrawPanel.transform.parent = null;
m_goFingerTailUIDrawPanel.transform.localPosition = Vector3.zero;
m_goFingerTailUIDrawPanel.transform.localScale = new Vector3(1, 1, 1);
m_MFUIFingerTail = m_goFingerTailUIDrawRange.AddComponent<MFUIFingerTail>();
m_MFUIFingerTail.UICamera = GameObject.Find("Camera").GetComponentsInChildren<Camera>(true)[0];
m_MFUIFingerTail.GoTail = m_goFingerTailUIDrawPanel;
m_MFUIFingerTail.TailWidth = 20;
m_MFUIFingerTail.LoadResourceInsteadOfAwake();
}
示例14: SavePanelChildren
public static void SavePanelChildren( GameObject savedObj , ref List<SceneData.SceneNodeData> nodelist , ref ISpriteFactory spriteFact )
{
nodelist.Clear();
// savedObj <== named "SavedLayer" GameObject and this is not serialized.
int count = savedObj.transform.GetChildCount();
if( count > 0 ){
for(int i=0;i<count;i++){
GameObject childObj = savedObj.transform.GetChild( i ).gameObject;
SaveDataRecursively( childObj ,ref nodelist , ref spriteFact );
}
}
// TEST . TEXT BOX POSITION SAVE.
/*
SceneData.SceneNodeData dat = new SceneData.SceneNodeData();
GameObject _TEXTBOX = GameObject.Find( "TextBox" );
if( _TEXTBOX != null ){
dat.nodeType = SceneNodeType.NODE;
nodelist.Add( dat );
spriteFact.SaveData( ref dat , _TEXTBOX );
}
else{
ViNoDebugger.LogError( "TextBox Not Found !" );
}
//*/
}
示例15: Start
// Use this for initialization
void Start()
{
GlobalValues.statePc = pcMovement;
timeSpent = 1.0f;
camera = GameObject.Find ("Main Camera");
meatballPlane = GameObject.Find ("Meatball Plane");
}