本文整理汇总了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!");
}
}