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


C# GameObject.Initialize方法代码示例

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


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

示例1: CreateDivision

	private PathDivision CreateDivision(float xStart) {
		PathDivision division = new GameObject("", typeof(PathDivision)).GetComponent<PathDivision>();
		division.transform.SetParent(transform);
		division.Initialize(path, xStart, xStart + divisionSize);
		division.name = "Path Division (" + ((int)xStart).ToString() + ")";
		division.transform.position = path.bottomContour.GetPointAtX(division.xRange.min);
		return division;
	}
开发者ID:wtrebella,项目名称:Grappler,代码行数:8,代码来源:PathDivisionManager.cs

示例2: GenerateCrowd

 /// <summary>
 /// Generates a crowd with the given arguments.
 /// </summary>
 /// <param name="criteria">The crowd's criteria</param>
 /// <param name="isStatic">Are the crowd's members static?</param>
 /// <param name="collection">The crowd's event scheduler.</param>
 public SmartCrowd GenerateCrowd(ISmartCrowdCriteria criteria, bool isStatic, EventCollection collection)
 {
     SmartCrowd instance = new GameObject(NamePrefix + currentCrowdIndex).AddComponent<SmartCrowd>();
     instance.tag = "Smart Object";
     if (Parent != null)
     {
         instance.transform.parent = Parent.transform;
     }
     instance.Initialize(criteria, isStatic, collection);
     instance.Portrait = GetPortrait(currentCrowdIndex);
     currentCrowdIndex++;
     return instance;
 }
开发者ID:fgeraci,项目名称:CS195-Core,代码行数:19,代码来源:CrowdGenerator.cs

示例3: Create

	public IEnumerator Create () {
		if (materials == null) {
			InitializeMaterials();
		}
		if(depth > 0)
			transform.Rotate(Random.Range (-maxTwist, maxTwist), 0f, 0f);
		if(this.GetComponent<MeshFilter>() == null) {
			gameObject.AddComponent<MeshFilter>().mesh = mesh;
			gameObject.AddComponent<MeshRenderer>().material = materials[usedColor];
		}
		if(depth < maxDepth) {
			for (int i = 0; i < childDirections.Length; i++) {
				if(Random.value < spawnProbability || depth == 0) {
					Fractal go = new GameObject("Fractal Child").AddComponent<Fractal>();
					go.Initialize(this, i);
					Vector3 scale = go.transform.localScale;
					go.transform.scaleFrom(.2f,Vector3.zero);
					yield return new WaitForSeconds(.2f);
				}
			}
		}
		if(depth == 0) {		
			FractalMaster = this;
		} else {
			NonMasterFractals.Add(this);
		}
		usedColor ++;
		if(usedColor >= materials.Length) {
			usedColor = 0;
		}
	}
开发者ID:Wuzseen,项目名称:Circuit-Math,代码行数:31,代码来源:Fractal.cs

示例4: GetGameObject

        public IGameObject GetGameObject(string name, float x = 0f, float y = 0f, bool usedAsTemplate = false)
        {
            //If we don't already have a template then generate one first
            if (!gameObjectTemplates.ContainsKey(name))
            {
                var generated = GenerateTemplate(name);

                if (!generated)
                {
                    throw new Exception(string.Format("Could not find a definition for the named game object: {0}", name));
                }
            }

            var template = gameObjectTemplates[name];
            var newObject = new GameObject();//rawPool.New();

            template.CopyInto(newObject);
            newObject.Position = new Vector2(x, y);

            newObject.Initialize();

            if (!usedAsTemplate)
                FireOnGameObjectCreated(newObject);

            return newObject;
        }
开发者ID:shadercoder,项目名称:Icicle-Framework,代码行数:26,代码来源:GameObjectFactory.cs

示例5: AddGameObject

 /// <summary>
 /// initializes objects and adds it to the game field
 /// </summary>
 /// <param name="obj"></param>
 public void AddGameObject(GameObject obj)
 {
     obj.Initialize(Content);
     _newObjects.Add(obj);
 }
开发者ID:vitaly-kobzev,项目名称:WindowsGSM1,代码行数:9,代码来源:Engine.cs

示例6: SpawnObject

        /* 
		 * 
		 * GameObject's management
		 * 
		 */

        public void SpawnObject(string name, GameObject obj)
        {
            obj.Name = name;
            obj.Engine = this;
            obj.Enabled = true;
            obj.Id = totalObjCount++;
            Objects[name] = obj;
            dirtyObjects[obj] = 1;
            obj.Initialize();
        }
开发者ID:luxkun,项目名称:AEngine,代码行数:16,代码来源:Engine.cs

示例7: BuildScreen

	public virtual GameObject BuildScreen( GUIScreen screen, GUIEditScreenInfo esi )
	{
		GameObject newobj = new GameObject(name);
		if ( newobj != null )
		{
			GUIEditObject eo = newobj.AddComponent(typeof(GUIEditObject)) as GUIEditObject;
			eo.guiScreen = screen;
			eo.name = screen.name;			
			eo.LoadedXML = loadedXML;
			eo.editSI = esi;
			// add all the objects below this
			foreach( GUIObject guiObj in screen.Elements )
				BuildObject(newobj, guiObj);	
			// set game object
			this.screen = newobj;
			// initialize (sets up all skins/styles)
			screen.Initialize(esi.ScreenInfo);
		}
		
		return newobj;
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:21,代码来源:GUIEditInspector.cs

示例8: Initialize

        public override void Initialize(out GameObject _root)
        {
            _root = new GameObject();
            _root.AddComponent(new EventController());

            m_background = new GameObject();
            m_background.transform.parent = _root.transform;
            _root.GetComponent<EventController>().AddEvent(new Event(m_background.AddComponent(new MenuBackground(m_background1, m_background2, 110f)), "Start", null, 5f));
            m_background.Initialize();

            m_arrow = new GameObject();
            m_arrow.AddComponent(new Animation(new Spritesheet(m_arrowSheet, 8), 0.125f));
            m_arrow.AddComponent(new MusicComponent(m_menuSelect));

            m_menu = new GameObject();
            m_menu.transform.parent = _root.transform;
            m_menu.transform.position += new Vector2(10f, 75f);
            m_menu.AddComponent(new UIMenu(new string[] { "Start Game", "Options", "Tutorial" }, Alignment.Left, 1f, Color.White, m_standartPixelFont, m_arrow));
            _root.GetComponent<EventController>().AddEvent(new Event(m_menu.AddComponent(new Fade(Color.TransparentBlack)), "NewFade", new object[] { Color.White, 1f }, 40f));
            m_menu.Initialize();

            m_blueShip = new GameObject();
            m_blueShip.transform.parent = _root.transform;
            m_blueShip.transform.position = new Vector2(-150, -200f);
            m_blueShip.active = false;
            m_blueShip.AddComponent(new SpriteRenderer(m_blueShipTexture));
            m_blueShip.AddComponent(new MoveObject(new Vector2(5f, -25), Vector2.Zero, (float)Math.PI / 6f, 3f));
            _root.GetComponent<EventController>().AddEvent(new Event(m_blueShip.AddComponent(new Activator()), "Activate", null, 27f));
            m_blueShip.Initialize();

            m_redShip = new GameObject();
            m_redShip.transform.parent = _root.transform;
            m_redShip.transform.position = new Vector2(0, 200f);
            m_redShip.active = false;
            m_redShip.AddComponent(new SpriteRenderer(m_redShipTexture));
            m_redShip.AddComponent(new MoveObject(new Vector2(25f, -10f), Vector2.Zero, (float)Math.PI / 6f, 3f));
            _root.GetComponent<EventController>().AddEvent(new Event(m_redShip.AddComponent(new Activator()), "Activate", null, 28.5f));
            m_redShip.Initialize();

            m_greenShip = new GameObject();
            m_greenShip.transform.parent = _root.transform;
            m_greenShip.transform.position = new Vector2(150f, -50f);
            m_greenShip.active = false;
            m_greenShip.AddComponent(new SpriteRenderer(m_greenShipTexture));
            m_greenShip.AddComponent(new MoveObject(new Vector2(20f, 30f), Vector2.Zero, (float)Math.PI / 6f, 2f));
            _root.GetComponent<EventController>().AddEvent(new Event(m_greenShip.AddComponent(new Activator()), "Activate", null, 31f));
            m_greenShip.Initialize();

            m_title = new GameObject();
            m_title.transform.parent = _root.transform;
            m_title.transform.position -= new Vector2(0f, 20f);
            m_title.AddComponent(new SpriteRenderer(m_titleTexture));
            _root.GetComponent<EventController>().AddEvent(new Event(m_title.AddComponent(new Fade(Color.TransparentBlack)), "NewFade", new object[] { Color.White, 1f }, 37f));
            m_title.Initialize();

            m_subtitle = new GameObject();
            m_subtitle.transform.parent = _root.transform;
            m_subtitle.transform.position += new Vector2(0f, 20f);
            m_subtitle.AddComponent(new SpriteRenderer(m_subtitleTexture));
            _root.GetComponent<EventController>().AddEvent(new Event(m_subtitle.AddComponent(new Fade(Color.TransparentBlack)), "NewFade", new object[] { Color.White, 1f }, 37f));
            m_subtitle.Initialize();

            m_titleMusicObject = new GameObject();
            m_titleMusicObject.transform.parent = _root.transform;
            _root.GetComponent<EventController>().AddEvent(new Event(m_titleMusicObject.AddComponent(new MusicComponent(m_titleMusic)), "Play", null, 4f));
            m_titleMusicObject.Initialize();

            m_segaLogo = new GameObject();
            m_segaLogo.transform.parent = _root.transform;
            m_segaLogo.transform.scale = new Vector2(0.181f, 0.181f);
            m_segaLogo.AddComponent(new Animation(new Spritesheet(m_segaLogoSheet, new Vector2(500, 165)), 0.0825f));
            _root.GetComponent<EventController>().AddEvent(new Event(m_segaLogo.AddComponent(new Fade(Color.White)), "NewFade", new object[] { Color.TransparentBlack, 0.5f }, 3.5f));
            _root.GetComponent<EventController>().AddEvent(new Event(m_segaLogo.AddComponent(new Activator()), "Deactivate", null, 4f));
            m_segaLogo.Initialize();

            m_logo = new GameObject();
            m_logo.transform.parent = _root.transform;
            m_logo.AddComponent(new SpriteRenderer(m_logoTexture));
            Fade logoFade = (Fade)m_logo.AddComponent(new Fade(Color.TransparentBlack));
            _root.GetComponent<EventController>().AddEvent(new Event(logoFade, "NewFade", new object[] { Color.White, 1f }, 9f));
            _root.GetComponent<EventController>().AddEvent(new Event(logoFade, "NewFade", new object[] { Color.TransparentBlack, 1f }, 15f));
            m_logo.Initialize();

            m_presents = new GameObject();
            m_presents.transform.parent = _root.transform;
            m_presents.AddComponent(new UIText("Presents", m_standartPixelFont, Color.White));
            Fade presentsFade = (Fade)m_presents.AddComponent(new Fade(Color.TransparentBlack));
            _root.GetComponent<EventController>().AddEvent(new Event(presentsFade, "NewFade", new object[] { Color.White, 1f }, 16f));
            _root.GetComponent<EventController>().AddEvent(new Event(presentsFade, "NewFade", new object[] { Color.TransparentBlack, 1f }, 22f));
            m_presents.Initialize();

            Game1.LoadScene("AccelCourse.Editor");
        }
开发者ID:Hyatukate,项目名称:DuneII-Remake,代码行数:93,代码来源:Menu.cs


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