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


C# Rigidbody.GetInstanceID方法代码示例

本文整理汇总了C#中UnityEngine.Rigidbody.GetInstanceID方法的典型用法代码示例。如果您正苦于以下问题:C# Rigidbody.GetInstanceID方法的具体用法?C# Rigidbody.GetInstanceID怎么用?C# Rigidbody.GetInstanceID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Rigidbody的用法示例。


在下文中一共展示了Rigidbody.GetInstanceID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: createAtom

    // this method creates a new atom from the type of the preFab and checks the position to have a far enough distance from other atoms
    public void createAtom(Rigidbody preFab)
    {
        int preFabID = preFab.GetInstanceID();
        if(preFabID == atomTouchGUI.copperPrefab.GetInstanceID()){
            Copper.count++;
            atomTouchGUI.copperCount.GetComponent<Text>().text = "Cu: " + Copper.count;
        }else if(preFabID == atomTouchGUI.goldPrefab.GetInstanceID()){
            Gold.count++;
            atomTouchGUI.goldCount.GetComponent<Text>().text = "Au: " + Gold.count;
        }else if(preFabID == atomTouchGUI.platinumPrefab.GetInstanceID()){
            Platinum.count++;
            atomTouchGUI.platinumCount.GetComponent<Text>().text = "Pt: " + Platinum.count;
        }
        CreateEnvironment myEnvironment = CreateEnvironment.myEnvironment;
        Quaternion curRotation = Quaternion.Euler(0, 0, 0);
        preFab.gameObject.GetComponent<MeshRenderer>().enabled = SettingsControl.renderAtoms;
        Debug.Log ("Rendering Atoms");

        Instantiate(preFab, myEnvironment.centerPos, curRotation);

        int i = Atom.AllAtoms.Count-1;
        Atom currAtom = Atom.AllAtoms[i];
        currAtom.gameObject.name = currAtom.GetInstanceID().ToString();
        //Debug.Log(currAtom.GetInstanceID());
        currAtom.GetComponent<Rigidbody>().freezeRotation = true;
        currAtom.GetComponent<TrailRenderer>().enabled = SettingsControl.mySettings.trailsToggle.isOn;

        float realWidth = myEnvironment.width - 2.0f * myEnvironment.errorBuffer;
        float realHeight = myEnvironment.height - 2.0f * myEnvironment.errorBuffer;
        float realDepth = myEnvironment.depth - 2.0f * myEnvironment.errorBuffer;
        Vector3 centerPos = myEnvironment.centerPos;

        int tryNumber = 0;

        bool proximityFlag = false;
        while ((proximityFlag == false) && (tryNumber < 100))
        {
            tryNumber ++;
            currAtom.position =  new Vector3 (centerPos.x + (UnityEngine.Random.Range (-realWidth/2.0f, realWidth/2.0f)), centerPos.y + (UnityEngine.Random.Range (-realHeight/2.0f, realHeight/2.0f)), centerPos.z + (UnityEngine.Random.Range (-realDepth/2.0f, realDepth/2.0f)));
            proximityFlag = myEnvironment.checkProximity(currAtom);
        }
        currAtom.transform.position = currAtom.position;
        StartCoroutine(Blink(currAtom));
        //kick it
        atomTouchGUI.AtomKick(i);
        Potential.myPotential.calculateVerletRadius (currAtom);

        if ((tryNumber == 100) && (proximityFlag == false))
        {
            Atom.UnregisterAtom(currAtom);
            Destroy (currAtom.gameObject);
            Debug.Log ("No space for atoms!");
        }
    }
开发者ID:fielddaylab,项目名称:atomtouch,代码行数:55,代码来源:CreateEnvironment.cs


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