本文整理汇总了C#中GameObject.SetName方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.SetName方法的具体用法?C# GameObject.SetName怎么用?C# GameObject.SetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObject
的用法示例。
在下文中一共展示了GameObject.SetName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CMD_AppendNumber
public static void CMD_AppendNumber(GameObject obj)
{
IEnumerable<GameObject> objenum = null;
if (obj.transform.GetParent() == null)
objenum = EngineManagerViewModel.instance.CurrentGameObjects.AsEnumerable<GameObject>();
else
{
Converters.CTransformListToGameObjectListConverter conv = new Converters.CTransformListToGameObjectListConverter();
objenum = (conv.Convert(obj.transform.GetParent().children,null, null, null) as ObservableCollection<GameObject>).AsEnumerable<GameObject>();
}
string obj_name = obj.GetName();
for (int i = 0; i < obj_name.Length; ++i)
{
if (char.IsDigit(obj_name[i]))
{
obj_name = obj_name.Remove(i);
break;
}
}
obj_name = obj_name.Trim();
int index = objenum.Count(new Func<GameObject,bool>((GameObject g)=>{ return g.GetName().Contains(obj_name); }));
obj.SetName(obj_name + " " + index.ToString());
}
示例2: OnStart
public void OnStart()
{
sound = gameObject.RequireComponent<CSound>();
consoleText = Common.GetSurveillancePlayerConsoleText().RequireComponent<CFontRenderer>();
// consoleText.mFontSize = 60;
// consoleText.mFontScale = 0.0024f;
mBlinkingTimer = 0.0f;
consoleText.mText = "";
firstLineTextToDisplay = "";
btmTextToDisplay = "";
playerMouse = GetScript<Mouse>(Common.GetStealthPlayerMouse());
player = Common.GetStealthPlayer();
mBlinkingLight = GetScript<OcuConsoleBlinkingLight>(Common.GetConsoleBlinkingLight());
mCenterPosForText = Common.GetConsoleCam().transform.position; // console: -10, 25
mCenterPosForText.Z = consoleText.gameObject.transform.position.z;
mExtraTexts = new List<GameObject>();
if (mColorOfText == null || mColorOfText.Comp(SharpMocha.BLACK))
{
mColorOfText = mDColorOfText;
}
mHeaderTextObj = ObjectFactory.getInstance().Instantiate(Common.nameForFixedWidthText);
mHeaderTextObj.SetName("ConsoleHeaderText");
Vector3 headerPos = mCenterPosForText;
headerPos.X -= 3.3f; //-13.40, 26.8
headerPos.Y += 1.8f;
mHeaderTextObj.transform.SetPosition(headerPos);
mHeaderFont = mHeaderTextObj.GetComponent<CFontRenderer>();
mHeaderFont.mText = "";
mHeaderFont.mJustification = CFontRenderer.FONT_JUSTIFICATION.LEFT_JUSTIFIED;
ChangeHeader(defaultHeaderText);
mNextMessageTimer = 0.0f;
mMessageQueue = new LinkedList<Tuple<String, float, bool> >();
QueueMessage("System Initializing...", 0.0f, false, false);
QueueMessage("Enabling Camera Systems.", 0.7f, false, false);
QueueMessage("Enabling Map Systems.", 0.4f, false, false);
QueueMessage("Enabling Door Security Systems.", 0.3f, false, false);
QueueMessage("System Ready.", 0.7f, false, false);
mTextToDisplay.AddFirst("> ");
UpdateConsoleTextFromQueue();
hasConsoleTextChanged = 0;
}
示例3: AddCameraObjectToList
// Adds to the camInMap, camInMapArea, and camInWorld lists
public static void AddCameraObjectToList(GameObject inCamInWorld, out GameObject retCamInMap, out GameObject retCamInMapArea)
{
// Ensure they are initialized
GetCamsInMap();
GetCamsInMapArea();
GetCamsInWorld();
retCamInMap = null;
retCamInMapArea = null;
if (inCamInWorld.GetName().StartsWith(nameForCamInWorld))
{
// Sort and change name based on CamInWorld (parent)'s name
String camIndexStr1 = inCamInWorld.transform.GetParent().gameObject.GetName();
camIndexStr1 = camIndexStr1.Substring(nameForCamInWorldParent.Length);
int index = Convert.ToInt32(camIndexStr1);
inCamInWorld.SetName(nameForCamInWorld + camIndexStr1);
//String camIndexStr = inCamInWorld.GetName().Substring(nameForCamInWorld.Length);
//int index = Convert.ToInt32(camIndexStr);
camInWorld.Add(inCamInWorld);
// Sort the physical CamInWorld# by name, so [0] == CamInMap1 and so on, with StickyCamInMap being the last
camInWorld.Sort(CompareCamInWorld);
retCamInMapArea = null;
retCamInMap = ObjectFactory.getInstance().Instantiate("CamInMap");
retCamInMap.SetName(nameForCamInMap + index.ToString());
for (uint i = 0; i < retCamInMap.transform.GetNumberOfChildren(); ++i)
{
if (retCamInMap.transform.GetChild(i).gameObject.GetName() == nameForCamInMapArea)
{
retCamInMapArea = retCamInMap.transform.GetChild(i).gameObject;
retCamInMapArea.SetName(nameForCamInMapArea + index.ToString());
camInMapArea.Add(retCamInMapArea);
break;
}
}
retCamInMap.transform.SetParent(GetMapScreen().transform.GetParent());
camInMap.Add(retCamInMap);
camInMap.Sort(CompareCamInMap);
camInMapArea.Sort(CompareCamInMapArea);
}
else
{
Logger.Log("Adding camera to list: name not normal: " + inCamInWorld.GetName());
if (inCamInWorld.GetName() == nameForStickyCamInWorld)
{
stickCam = inCamInWorld;
retCamInMap = ObjectFactory.getInstance().Instantiate("CamInMap");
retCamInMap.SetName(nameForStickyCamInMap);
for (uint i = 0; i < retCamInMap.transform.GetNumberOfChildren(); ++i)
{
if (retCamInMap.transform.GetChild(i).gameObject.GetName() == nameForCamInMapArea)
{
retCamInMapArea = retCamInMap.transform.GetChild(i).gameObject;
retCamInMapArea.SetName(nameForStickyCamInMap + "Area");
stickCamInMapArea = retCamInMapArea;
break;
}
}
retCamInMap.transform.SetParent(GetMapScreen().transform.GetParent());
stickCamInMap = retCamInMap;
}
else if (inCamInWorld.GetName() == nameForRCCarCamInWorld)
{
rcCarCam = inCamInWorld;
retCamInMap = ObjectFactory.getInstance().Instantiate("CamInMap");
retCamInMap.SetName(nameForRCCarCamInMap);
for (uint i = 0; i < retCamInMap.transform.GetNumberOfChildren(); ++i)
{
if (retCamInMap.transform.GetChild(i).gameObject.GetName() == nameForCamInMapArea)
{
retCamInMapArea = retCamInMap.transform.GetChild(i).gameObject;
retCamInMapArea.SetName(nameForRCCarCamInMap + "Area");
break;
}
}
retCamInMap.transform.SetParent(GetMapScreen().transform.GetParent());
rcCarCamInMap = retCamInMap;
}
}
}