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


C# GameObject类代码示例

本文整理汇总了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>();
	}
开发者ID:paulodgn,项目名称:humanity_Ambientes,代码行数:8,代码来源:playerGetBullets.cs

示例2: OnDrop

	void OnDrop (GameObject go)
	{
		if (onDrop && target != null)
		{
			target.SendMessage("OnDrop", go, SendMessageOptions.DontRequireReceiver);
		}
	}
开发者ID:BigBearGCU,项目名称:Quantum-LD48,代码行数:7,代码来源:UIForwardEvents.cs

示例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));
						}
					}
				}
			}
		}
	}
开发者ID:YaFengYi,项目名称:Unity,代码行数:31,代码来源:MissingReferencesFinder.cs

示例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;
    }
开发者ID:rogeryuan99,项目名称:Hello,代码行数:28,代码来源:SkillTreeDlg.cs

示例5: onPickupClock

	public void onPickupClock(GameObject go, bool tr) {
		Interactable inter = go.GetComponent<Interactable>();
		if(inter != null) {
			//TODO Start ticking sound
			inter.setPuzzleState("pickedUp");
		}
	}
开发者ID:Backman,项目名称:Hellbound,代码行数:7,代码来源:Death_ClockPuzzle.cs

示例6: ItWillHaveTheGameObjectSet

 public void ItWillHaveTheGameObjectSet()
 {
     GameObject go = new GameObject();
     Component comp = new TestComponent();
     go.AddComponent(comp);
     Assert.That(comp.gameObject, Is.SameAs(go));
 }
开发者ID:Joelone,项目名称:FFWD,代码行数:7,代码来源:WhenAddingAComponentToAGameObject.cs

示例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");
     }
 }
开发者ID:Marcos1994,项目名称:Luria,代码行数:25,代码来源:AcoesJogadorAlvo.cs

示例8: Start

    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");

        anim = GetComponent<Animator>();
        charControl = GetComponent<CharacterController>();
    }
开发者ID:DanStout,项目名称:FablesOfSol,代码行数:7,代码来源:ChasesPlayer.cs

示例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) {
            }
        }
    }
开发者ID:BibleUs,项目名称:vgd-monopoly-uniba,代码行数:35,代码来源:GlobalBuildingCompany.cs

示例10: OnCreate

 private static void OnCreate(GameObject sender, EventArgs args)
 {
     if (sender.Name.Contains("healingBuff"))
     {
         _healingBuffs.Add(sender);
     }
 }
开发者ID:Hyunabstar,项目名称:Experimental,代码行数:7,代码来源:Cache.cs

示例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;
    }
开发者ID:chocomellon,项目名称:BattleArms,代码行数:26,代码来源:AI2.cs

示例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");
		}
	}
开发者ID:fierceblaze,项目名称:SolarSystemSimulation,代码行数:9,代码来源:LookAtTarget.cs

示例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();
    }
开发者ID:lbddk,项目名称:ahzs-client,代码行数:25,代码来源:FingerTailUIViewManager.cs

示例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 !" );
        }
        //*/
    }
开发者ID:Joon-min,项目名称:wiper,代码行数:27,代码来源:ViNoSceneSaveUtil.cs

示例15: Start

 // Use this for initialization
 void Start()
 {
     GlobalValues.statePc = pcMovement;
     timeSpent = 1.0f;
     camera = GameObject.Find ("Main Camera");
     meatballPlane = GameObject.Find ("Meatball Plane");
 }
开发者ID:hubbas,项目名称:Arabic-Game-Jam,代码行数:8,代码来源:Movement.cs


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