• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# GameObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



GameObject类属于命名空间,在下文中一共展示了GameObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Spawn_Diamond

    protected void Spawn_Diamond(GameObject Tile, float Movement)
    {
        Spawn_Tile (Tile, Vector2.zero);
        for (int i = 0; i <= Movement; i++)
         		{
            Vector2 Spawn_Position = Vector.Up * i;
            for (int iSpawn = 0; iSpawn < i; iSpawn++)
            {
                Spawn_Position += Vector.Right;
                Spawn_Position += Vector.Down;
                Spawn_Tile(Tile, Spawn_Position);
            }

            for (int iSpawn = 0; iSpawn < i; iSpawn++)
            {
                Spawn_Position += Vector.Down;
                Spawn_Position += Vector.Left;
                Spawn_Tile(Tile, Spawn_Position);
            }

            for (int iSpawn = 0; iSpawn < i; iSpawn++)
            {
                Spawn_Position += Vector.Left;
                Spawn_Position += Vector.Up;
                Spawn_Tile(Tile, Spawn_Position);
            }

            for (int iSpawn = 0; iSpawn < i; iSpawn++)
            {
                Spawn_Position += Vector.Up;
                Spawn_Position += Vector.Right;
                Spawn_Tile(Tile, Spawn_Position);
            }
        }
    }
开发者ID:phoenixanimations,项目名称:Port-02,代码行数:35,代码来源:Grid_Pattern.cs


示例17: Start

    // Use this for initialization
    void Start()
    {
        //for the comp time leaderboard
        CompTimeColum1 = GameObject.Find ("CompTimeRow1");
        CompTimeColum2 = GameObject.Find ("CompTimeRow2");
        CompTimeColum3 = GameObject.Find ("CompTimeRow3");
        CompTimeLine2 = GameObject.Find ("CompTimeLine2");

        //for the enemies killed leaderboard
        EnemieskilledColum1 = GameObject.Find ("EnemiesKilledRow1");
        EnemieskilledColum2 = GameObject.Find ("EnemiesKilledRow2");
        EnemieskilledColum3 = GameObject.Find ("EnemiesKilledRow3");
        EnemieskilledLine2 = GameObject.Find ("EnemiesKilledLine2");

        //for the least damage leaderboard
        LeastDamageColum1 = GameObject.Find ("LeastDamageRow1");
        LeastDamageColum2 = GameObject.Find ("LeastDamageRow2");
        LeastDamageColum3 = GameObject.Find ("LeastDamageRow3");
        LeastDamageLine2 = GameObject.Find ("LeastDamageLine2");

        ReadFile.Load ("Assets/Data Files/Leaderboard.txt"); // the file that is loaded

        CompletionTime ();
        EnemiesKilled ();
        LeastDamage ();

        //not needed on the leaderboard for the main menu, but will be needed when accessed from the end of game
        CompTimeLine2.SetActive (false);
        EnemieskilledLine2.SetActive (false);
        LeastDamageLine2.SetActive (false);
    }
开发者ID:DavidIllidge,项目名称:Portfolio,代码行数:32,代码来源:LeaderboardScript.cs


示例18: Spawn_Tile

 private void Spawn_Tile(GameObject Select_Tile, Vector2 Position)
 {
     GameObject Tile = Instantiate (Select_Tile);
     Tile.transform.parent = transform;
     Tile.transform.position = transform.position;
     Tile.transform.position += (Vector3)Position;
 }
开发者ID:phoenixanimations,项目名称:Port-02,代码行数:7,代码来源:Grid_Pattern.cs


示例19: CharaController

    public CharaController(CharaConfiguration chara, Configuration config, GameObject[] objs, bool debug = false)
    {
        _chara = chara;
        _config = config;

        _objs = objs;
        _joints = new ConfigurableJoint[_objs.Length];
        _rigs = new Rigidbody[_objs.Length];
        _init_rot = new Quaternion[_objs.Length];
        _target_rot = new Quaternion[_objs.Length];
        _target_pos = new Vector3[_objs.Length];

        _debug = debug;

        for (int i = 0; i < _objs.Length; ++i) {
            _rigs[i] = _objs[i].GetComponent<Rigidbody>();
            /*
            if (_debug)
                _rigs[i].isKinematic = true;
                */
            _init_rot[i] = _objs[i].transform.localRotation;
            _target_rot[i] = _init_rot[i];

            _joints[i] = _objs[i].GetComponent<ConfigurableJoint>();
        }

        InitializeJoints();
    }
开发者ID:yihengz,项目名称:UnityBiped,代码行数:28,代码来源:CharaController.cs


示例20: Move

 private void Move(GameObject prefab)
 {
     //move object upwards over time * speed
     Vector2 pos = prefab.GetComponent<RectTransform>().anchoredPosition;
     pos.y += 1 * speed * Time.deltaTime;
     prefab.GetComponent<RectTransform>().anchoredPosition = pos;
 }
开发者ID:kayetea,项目名称:EntertainmentApp,代码行数:7,代码来源:LoopImageStack.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# GameObjectIssueOrderEventArgs类代码示例发布时间:2022-05-24
下一篇:
C# GameNPC类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap