本文整理汇总了C#中GameObject.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.ToString方法的具体用法?C# GameObject.ToString怎么用?C# GameObject.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObject
的用法示例。
在下文中一共展示了GameObject.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetDestroyedCube
public int SetDestroyedCube(GameObject toDestroyingCube)
{
switch (toDestroyingCube.ToString())
{
case "DirtCube(Clone) (UnityEngine.GameObject)":
destroyedItem = 0;
break;
case "StoneCube(Clone) (UnityEngine.GameObject)":
destroyedItem = 1;
break;
case "Wooden_PlanksCube(Clone) (UnityEngine.GameObject)":
destroyedItem = 2;
break;
case "Copple_stone(Clone) (UnityEngine.GameObject)":
destroyedItem = 3;
break;
case "Gravel(Clone) (UnityEngine.GameObject)":
destroyedItem = 4;
break;
case "Sand(Clone) (UnityEngine.GameObject)":
destroyedItem = 5;
break;
case "Bedrock(Clone) (UnityEngine.GameObject)":
destroyedItem = 6;
break;
case "Obsidian(Clone) (UnityEngine.GameObject)":
destroyedItem = 7;
break;
case "Brick(Clone) (UnityEngine.GameObject)":
destroyedItem = 8;
break;
}
//print (destroyedItem);
return destroyedItem;
}
示例2: Check
void Check(GameObject obj)
{
//check gameObject's number
if(obj == objectList[count] && !bIsSolved)
{
Debug.Log ("Match! Obj: " + obj.ToString() + " Count: " + count + " ObjList: " + objectList[count].ToString());
Debug.Log ("Count List: " + objectList.Count);
if(count == objectList.Count - 1)
{
Open ();
bIsSolved = true;
this.gameObject.renderer.material.color = Color.green;
}
count++;
}
else
{
count = 0;
foreach(GameObject item in objectList)
{
objectList[count].SendMessage("Reset");
count++;
}
count = 0;
this.renderer.material.color = Color.red;
Debug.Log ("Reset! Count: " + count);
}
}
示例3: Start
// Use this for initialization
void Start()
{
gl = (GameLogic)FindObjectOfType(typeof(GameLogic));
ft = (FractalTexture)FindObjectOfType(typeof(FractalTexture));
pl = (Player)FindObjectOfType(typeof(Player));
whiteNoise = GameObject.Find("WhiteNoise");
Debug.Log("White Noise: " + whiteNoise.ToString());
}
示例4: Start
void Start() {
currentScene = Object.Instantiate (scenePrefabs[0]);
metricController = GetComponent<MetricController>();
totalTimeSpentDrinkingCoffee = 0.0f;
Debug.Log (currentScene.ToString ());
fader = c.GetComponent<Fade> ();
IsGameOver = false;
fader.FadeIn ();
}
示例5: setDrone
public void setDrone(int role, GameObject obj)
{
switch(role)
{
case 0: droneLeft = obj; break;
case 1: droneRight = obj; break;
case 2: droneBack = obj; break;
default: Debug.Log("Error : unknown role for drone "+obj.ToString()); break;
}
}
示例6: GetCache
static GameObject GetCache(GameObject G)
{
if (G == null)
throw new System.Exception("Constraint Spawner null object requested");
if (Cache == null) Cache = new Dictionary<GameObject, GameObject>();
if (!Cache.ContainsKey(G))
Cache[G] = (GameObject)Instantiate(G, new Vector3(0, -100, 0), new Quaternion());
if (!Cache.ContainsKey(G))
throw new System.Exception(G.ToString() + " Constraint spawner could not spawn blueprint");
return Cache[G];
}
示例7: LoadMagePrefs
void LoadMagePrefs()
{
selectedCharacter = Mage;
Debug.Log(selectedCharacter.ToString());
if (GameObject.Find("Picture"))
{
ImageOff.enabled = true;
GameObject SelectImage = GameObject.Find("CharacterPicture");
Image MagePicture = SelectImage.GetComponent<Image>();
MagePicture.sprite = MagePic;
}
if (GameObject.Find("Atributos"))
{
//Procura os gameobjects
GameObject WriteHP = GameObject.Find("HPText");
GameObject WriteMP = GameObject.Find("MPText");
GameObject WriteSTR = GameObject.Find("STRText");
GameObject WriteVIT = GameObject.Find("VITText");
GameObject WriteDEX = GameObject.Find("DEXText");
GameObject WriteINT = GameObject.Find("INTText");
//Escreve nas labels.
Text textHP = WriteHP.GetComponent<Text>();
textHP.text = "100".ToString();
Text textMP = WriteMP.GetComponent<Text>();
textMP.text = "150".ToString();
Text textSTR = WriteSTR.GetComponent<Text>();
textSTR.text = "7 *1.8".ToString();
Text textVIT = WriteVIT.GetComponent<Text>();
textVIT.text = "5 *1.7".ToString();
Text textDEX = WriteDEX.GetComponent<Text>();
textDEX.text = "5 * 1.7".ToString();
Text textINT = WriteINT.GetComponent<Text>();
textINT.text = "12 *1.5".ToString();
}
if (GameObject.Find("Skills"))
{
GameObject WriteSkill1 = GameObject.Find("Skill1Text");
GameObject WriteSkill2 = GameObject.Find("Skill2Text");
GameObject WriteSkill3 = GameObject.Find("Skill3Text");
Text textSkill1 = WriteSkill1.GetComponent<Text>();
textSkill1.text = "Fireball".ToString();
Text textSkill2 = WriteSkill2.GetComponent<Text>();
textSkill2.text = "Throw Stone".ToString();
Text textSkill3 = WriteSkill3.GetComponent<Text>();
textSkill3.text = "Water Blast".ToString();
}
}
示例8: Generate
void Generate()
{
if(numLeft > 0) {
current = GameObject.Instantiate(blockProto, Vector3.zero, Quaternion.identity) as GameObject;
Debug.Log (current.ToString());
Debug.Log (current.GetType ().ToString());
current.transform.SetParent (gameObject.transform);
current.transform.localPosition = new Vector3(0.6f, 0, 0);
current.transform.localScale = new Vector3(1, 1, 1);
current.GetComponent<ProgBlock>().onPickup += OnPickup;
}
}
示例9: Pool
public Pool(GameObject obj, GameObject parent, int size)
{
index = 0;
GameObject container = new GameObject("Pool"+obj.ToString());
container.transform.SetParent(parent.transform);
for (int i = 0; i < size; i++)
{
GameObject instance = GameObject.Instantiate(obj);
instance.transform.parent = container.transform;
instance.SetActive(false);
objects.Add(instance);
}
}
示例10: Assign
public override int Assign(GameObject entity)
{
if (entityMap [0] == null) {
FormationLeader = entity;
entityMap [0] = entity;
return 0;
} else if (entityMap [1] == null) {
entityMap [1] = entity;
return 1;
} else {
throw (new UnityException ("Tried to Assign entity " + entity.ToString () + " to a full formation."));
}
}
示例11: onSelection
public void onSelection(GameObject selected)
{
Debug.Log (selected.ToString());
if (buttons != null) {
foreach(Button b in buttons){
b.image.sprite = offSprite;
//Debug.Log(b.ToString);
}
Image i = selected.GetComponent<Image>();
i.sprite = onSprite;
}
}
示例12: EntityIs
/// <summary>
/// Checks to see if an entity is tagged with a specified tag
/// </summary>
/// <param name="Entity"></param>
/// <param name="Tag"></param>
/// <returns></returns>
public static bool EntityIs(GameObject Entity,Tag Tag)
{
EntityTag _Tag = Entity.GetComponent<EntityTag>();
if (!_Tag)
{
Debug.Log("Game Object does not contain an EntityTag: " + Entity.ToString());
return false;
}
else
{
return _Tag.Is(Tag);
}
}
示例13: errors
Color defaultGUI = Color.white; // set to white to avoid errors (Color is non-nullable)
#endregion Fields
#region Methods
// add an item to the inventory
public void AddItem(GroundItem i)
{
// only add items if there's room in the inventory
if (!IsFull())
{
// create a new game object and give it a held item script
GameObject toAdd = new GameObject(i.name);
toAdd.AddComponent<HeldItem>();
toAdd.GetComponent<HeldItem>().Initialize(i.GetComponent<SpriteRenderer>().sprite, i.cooldown);
toAdd.GetComponent<HeldItem>().projectile = i.projectile;
// add the new item to the inventory
inv[currentItems] = toAdd;
currentItems++;
Destroy(i.gameObject);
Debug.Log("Item \"" + toAdd.ToString() + "\" added to inventory");
}
}
示例14: cameraMove_Lerp
//void cameraTrack_Lerp(GameObject player)
//{
// //Vector3 playerPos =
// //mainCamera.transform.position = new Vector3(mainCamera.transform.position.x, player.transform.position.y, mainCamera.transform.position.z);
// Debug.Log("cameraTrack_Lerp called");
// Debug.Log("player available while rotation: " + player.ToString());
// float wantedHeight = player.transform.position.y;
// Vector3 targetPos = new Vector3(mainCamera.transform.position.x, wantedHeight, mainCamera.transform.position.z);
// mainCamera.transform.position = Vector3.Lerp(mainCamera.transform.position, targetPos, heightDamping * Time.deltaTime);
//}
private void cameraMove_Lerp(GameObject player)
{
if(_isAdjustingCamera == true)
{
//_isAdjustingCamera = true;
//mainCamera.transform.position = new Vector3(mainCamera.transform.position.x, player.transform.position.y, mainCamera.transform.position.z);
Debug.Log("cameraMove_Lerp called");
Debug.Log("player available while rotation: " + player.ToString());
float wantedHeight = player.transform.position.y;
float currentHeight = mainCamera.transform.position.y;
//Vector3 targetPos = new Vector3(mainCamera.transform.position.x, wantedHeight, mainCamera.transform.position.z);
Vector3 amount = new Vector3(0, wantedHeight - currentHeight, 0);
Debug.Log("amount" + amount);
//mainCamera.transform.position = Vector3.MoveTowards(mainCamera.transform.position, targetPos, heightDamping * Time.deltaTime);
//iTween.MoveAdd(mainCamera, amount, timeAdjustingCamera);
iTween.MoveAdd(mainCamera, iTween.Hash(iT.MoveAdd.time, timeAdjustingCamera, iT.MoveAdd.amount, amount, iT.MoveAdd.oncomplete, "onAdjustCameraComplete", iT.MoveAdd.oncompletetarget, gameObject));
}
}
示例15: Act
public override void Act(GameObject player, GameObject npc)
{
Debug.Log("FollowPath: ACT");
Debug.Log("FollowPath: player - "+player.ToString()+". npc - "+npc.ToString());
// Follow the path of waypoints
// Find the direction of the current way point
//Vector3 vel = npc.rigidbody.velocity;
Vector3 vel = npc.GetComponent<Rigidbody>().velocity;
Vector3 moveDir = waypoints[currentWayPoint].position - npc.transform.position;
if (moveDir.magnitude < 1)
{
currentWayPoint++;
Debug.Log("FollowPath: Incrementa WayPoint");
if (currentWayPoint >= waypoints.Length)
{
currentWayPoint = 0;
}
}
else
{
Debug.Log("FollowPath: SEGUINDO WayPoints");
vel = moveDir.normalized * NPCControl.GetVelocityFactor();
Debug.DrawRay(npc.transform.position,moveDir);
// Rotate towards the waypoint
npc.transform.rotation = Quaternion.Slerp(npc.transform.rotation,
Quaternion.LookRotation(moveDir),
2 * Time.deltaTime);
//npc.transform.rotation.ToAngleAxis(180f,Vector3.up);
//npc.transform.RotateAround(npc.transform.position,Vector3.up, 180.0f);
//npc.transform.rotation = Quaternion.LookRotation(moveDir);
npc.transform.eulerAngles = new Vector3(0, npc.transform.eulerAngles.y, 0);
}
// Apply the Velocity
//npc.rigidbody.velocity = vel;
npc.GetComponent<Rigidbody> ().velocity = vel;
}