UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine.Quaternion)

Here are the examples of the csharp api UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine.Quaternion) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

98 Examples 7

19 View Source File : AttackScript.cs
License : MIT License
Project Creator : HDNua

protected GameObject MakeReflectedParticle(bool right, Vector3 position)
    {
        GameObject particle = Instantiate
            (_ReflectedParticle, position, transform.rotation)
            as GameObject;

        // 버스터 속도의 반대쪽으로 적절히 x 반전합니다.
        if (right)
        {
            Vector3 newScale = particle.transform.localScale;
            newScale.x *= -1;
            particle.transform.localScale = newScale;
        }

        // 효과음을 재생합니다.
        EffectScript hitEffect = particle.GetComponent<EffectScript>();
        hitEffect.PlayEffectSound(SoundEffects[0].clip);

        // 생성한 효과 객체를 반환합니다.
        return particle;
    }

19 View Source File : Steam.cs
License : MIT License
Project Creator : Lallassu

void Awake () {
        for (int i = 0; i < maxDrains; i++) {
            GameObject g = (GameObject)Instantiate (drainSteam, new Vector3 (0, 0, 0), Quaternion.idenreplacedy);
            drainSteam.GetComponent<ParticleSystem> ().loop = true;
            drainSteam.GetComponent<ParticleSystem> ().Stop ();
            drainList.Add (g);
        }
    }

19 View Source File : BalloonSpawner.cs
License : MIT License
Project Creator : dag10

public GameObject SpawnBalloon( Balloon.BalloonColor color = Balloon.BalloonColor.Red )
		{
			if ( balloonPrefab == null )
			{
				return null;
			}
			GameObject balloon = Instantiate( balloonPrefab, transform.position, transform.rotation ) as GameObject;
			balloon.transform.localScale = new Vector3( scale, scale, scale );
			if ( attachBalloon )
			{
				balloon.transform.parent = transform;
			}

			if ( sendSpawnMessageToParent )
			{
				if ( transform.parent != null )
				{
					transform.parent.SendMessage( "OnBalloonSpawned", balloon, SendMessageOptions.DontRequireReceiver );
				}
			}

			if ( playSounds )
			{
				if ( inflateSound != null )
				{
					inflateSound.Play();
				}
				if ( stretchSound != null )
				{
					stretchSound.Play();
				}
			}
			balloon.GetComponentInChildren<Balloon>().SetColor( color );
			if ( spawnDirectionTransform != null )
			{
				balloon.GetComponentInChildren<Rigidbody>().AddForce( spawnDirectionTransform.forward * spawnForce );
			}

			return balloon;
		}

19 View Source File : Platform_Generator.cs
License : MIT License
Project Creator : ehsan-mohammadi

public void Generate_Platform(int Num)
    {
        for (int i = 0; i < Num; i++)
        {
            // Calculate platform x, y
            float Dist_X = Random.Range(Top_Left.x + Offset, -Top_Left.x - Offset);
            float Dist_Y = Random.Range(2f, 5f);

            // Create brown platform random with 1/8 probability
            int Rand_BrownPlatform = Random.Range(1, 8);

            if (Rand_BrownPlatform == 1)
            {
                float Brown_DistX = Random.Range(Top_Left.x + Offset, -Top_Left.x - Offset);
                float Brown_DistY = Random.Range(Current_Y + 1, Current_Y + Dist_Y - 1);
                Vector3 BrownPlatform_Pos = new Vector3(Brown_DistX, Brown_DistY, 0);

                Instantiate(Platform_Brown, BrownPlatform_Pos, Quaternion.idenreplacedy);
            }

            // Create other platform
            Current_Y += Dist_Y;
            Vector3 Platform_Pos = new Vector3(Dist_X, Current_Y, 0);
            int Rand_Platform = Random.Range(1, 10);

            if (Rand_Platform == 1) // Create blue platform
                Platform = Instantiate(Platform_Blue, Platform_Pos, Quaternion.idenreplacedy);
            else if (Rand_Platform == 2) // Create white platform
                Platform = Instantiate(Platform_White, Platform_Pos, Quaternion.idenreplacedy);
            else // Create green platform
                Platform = Instantiate(Platform_Green, Platform_Pos, Quaternion.idenreplacedy);

            if (Rand_Platform != 2)
            {
                // Create random objects; like spring, trampoline and etc...
                int Rand_Object = Random.Range(1, 40);

                if (Rand_Object == 4) // Create spring
                {
                    Vector3 Spring_Pos = new Vector3(Platform_Pos.x + 0.5f, Platform_Pos.y + 0.27f, 0);
                    Random_Object = Instantiate(Spring, Spring_Pos, Quaternion.idenreplacedy);
                    
                    // Set parent to object
                    Random_Object.transform.parent = Platform.transform;
                }
                else if (Rand_Object == 7) // Create trampoline
                {
                    Vector3 Trampoline_Pos = new Vector3(Platform_Pos.x + 0.13f, Platform_Pos.y + 0.25f, 0);
                    Random_Object = Instantiate(Trampoline, Trampoline_Pos, Quaternion.idenreplacedy);

                    // Set parent to object
                    Random_Object.transform.parent = Platform.transform;
                }
                else if (Rand_Object == 15) // Create propeller
                {
                    Vector3 Propeller_Pos = new Vector3(Platform_Pos.x + 0.13f, Platform_Pos.y + 0.15f, 0);
                    Random_Object = Instantiate(Propeller, Propeller_Pos, Quaternion.idenreplacedy);

                    // Set parent to object
                    Random_Object.transform.parent = Platform.transform;
                }
            }
        }
    }

19 View Source File : RandomMapMaker.cs
License : MIT License
Project Creator : Donut-Studios

void fillEdges()
	{
		// fill in edges along the width
		for (int i = 0; i < mapWidth; i++)
		{
			Instantiate(wallXHigh, new Vector3((i + 0.5f) * tileSize, 
				wallXHigh.transform.position.y, 0.5f * tileSize), Quaternion.idenreplacedy);
			Instantiate(wallXHigh, new Vector3((i + 0.5f) * tileSize,
				wallXHigh.transform.position.y, (mapHeight - 0.5f) * tileSize), Quaternion.idenreplacedy);
		}

		// fill in edges along the height
		for (int j = 0; j < mapHeight; j++)
		{
			Instantiate(wallZHigh, new Vector3(0.5f * tileSize,
				wallZHigh.transform.position.y, (j + 0.5f) * tileSize), Quaternion.idenreplacedy);
			Instantiate(wallZHigh, new Vector3((mapWidth - 0.5f) * tileSize,
				wallZHigh.transform.position.y, (j + 0.5f) * tileSize), Quaternion.idenreplacedy);
		}
	}

19 View Source File : SimpleGridGenerator.cs
License : MIT License
Project Creator : dag10

public void GenerateGrid()
    {
        float startX = -0.5f * ObjectSpacing * (Rows - 1);
        float startY = -0.5f * ObjectSpacing * (Columns - 1);
        for (int i = 0; i < Rows; i++)
        {
            for (int j = 0; j < Columns; j++)
            {
                GameObject prefab = GetRandomPrefab();
                Vector3 pos = new Vector3(startX + i * ObjectSpacing, startY + j * ObjectSpacing, 0.0f);
                GameObject go = Instantiate(prefab, pos, Quaternion.idenreplacedy) as GameObject;
                go.transform.SetParent(transform, false);
            }
        }
    }

19 View Source File : ExplosionFireAndDebris.cs
License : MIT License
Project Creator : joanby

private void AddFire(Transform t, Vector3 pos, Vector3 normal)
        {
            pos += normal*0.5f;
            Transform fire = (Transform) Instantiate(firePrefab, pos, Quaternion.idenreplacedy);
            fire.parent = t;
        }

19 View Source File : GreateFood.cs
License : MIT License
Project Creator : BelkinAndrey

void Update() 
    {
        if (Input.GetMouseButtonDown(1)) 
        {
            Vector3 Pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Pos.z = 0f;

            if (prefabFood != null)
            {
                Collider2D[] hit = Physics2D.OverlapPointAll(Camera.main.ScreenToWorldPoint(Input.mousePosition));
                if (hit.Length > 0)
                {
                    if (hit[0].tag == "food") 
                    {
                        Destroy(hit[0].gameObject);
                    }

                }
                else
                {
                    GameObject clone = Instantiate(prefabFood, Pos, transform.rotation) as GameObject;
                    clone.name = "food";
                    clone.transform.Rotate(Vector3.forward, Random.Range(-20f, 20f));

                    if (head != null) clone.GetComponent<FoodManager>().head = head;
                    clone.GetComponent<FoodManager>().manager = gameObject;

                    clone.GetComponent<SpriteRenderer>().sprite = sprites[Random.Range(0, sprites.Length)];
                }
            }
        }
    }

19 View Source File : uUIPopupList.cs
License : MIT License
Project Creator : mamoniem

void OnUpdateList(){
        if (theItemsList.Count != 0){
            scrollLisreplacedemsObjects = new RectTransform[theItemsList.Count];
            GameObject processingMenuItem;
            processingMenuItem = (GameObject) Instantiate (theItemSample.gameObject, theItemSample.transform.position, theItemSample.transform.rotation);
            processingMenuItem.GetComponentInChildren<Text>().text = theItemsList[0];
            processingMenuItem.gameObject.name = theItemsList[0];
            scrollLisreplacedemsObjects[0] = processingMenuItem.GetComponent<RectTransform>();
            scrollLisreplacedemsObjects[0].SetParent(theItemSample.transform.parent);
            for (int c=1; c<theItemsList.Count; c++){
                Vector3 theNewPositon = new Vector3 (scrollLisreplacedemsObjects[c-1].transform.position.x,
                                                     scrollLisreplacedemsObjects[c-1].transform.position.y - (scrollLisreplacedemsObjects[c-1].rect.height+distanceBetweenItems), 
                                                     scrollLisreplacedemsObjects[c-1].transform.position.z);
                processingMenuItem = (GameObject) Instantiate (theItemSample.gameObject, theNewPositon, theItemSample.transform.rotation);
                processingMenuItem.GetComponentInChildren<Text>().text = theItemsList[c];
                processingMenuItem.gameObject.name = theItemsList[c];
                scrollLisreplacedemsObjects[c] = processingMenuItem.GetComponent<RectTransform>();
                scrollLisreplacedemsObjects[c].SetParent(theItemSample.transform.parent);
            }
            theItemSample.SetActive(false);
            
			theList.GetComponent<ScrollRect>().content.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(theList.GetComponent<ScrollRect>().content.gameObject.GetComponent<RectTransform>().sizeDelta.x,
                                                                                                                    /* scrollLisreplacedemsObjects[scrollLisreplacedemsObjects.Length-1].position.y+scrollLisreplacedemsObjects[scrollLisreplacedemsObjects.Length-1].sizeDelta.y*/
                                                                                                                     scrollLisreplacedemsObjects[scrollLisreplacedemsObjects.Length-1].sizeDelta.y*scrollLisreplacedemsObjects.Length);
			Vector3 tempPos =  theList.GetComponent<ScrollRect>().content.gameObject.GetComponent<RectTransform>().position;
			tempPos.y = theList.GetComponent<ScrollRect>().content.rect.position.y*2;
			theList.GetComponent<ScrollRect>().content.gameObject.GetComponent<RectTransform>().position = tempPos;
        }
		SetSelection(theItemsList[0]);
    }

19 View Source File : World.cs
License : MIT License
Project Creator : BrunoS3D

void Update() {
        if (randomize) {
            noiseScale = Random.Range(32, 128);
            noiseOffset = Random.insideUnitSphere * noiseScale * noiseScale;
            for (int idx = 0; idx < chunkMap.Count; idx++) {
                Chunk chunk = chunkMap[idx];
                StartCoroutine(chunk.GenerateChunk());
            }
            randomize = false;
            return;
        }

        Vector3 ppos = player.position;
        t_chunckUpdateTime += Time.deltaTime;

        for (int idx = 0; idx < chunkMap.Count; idx++) {
            Chunk chunk = chunkMap[idx];
            CloudsChunk cloudsChunk = cloudsChunkMap[idx];

            Vector2 biPlayerPos = new Vector2(player.position.x, player.position.z);
            Vector2 biChunkPos = new Vector2(chunk.transform.position.x, chunk.transform.position.z);

            bool activeChunk = Vector3.Distance(biPlayerPos, biChunkPos) <= playerFOV.magnitude;

            chunk.gameObject.SetActive(activeChunk);

            if (activeChunk) {
                chunk.gameObject.SetActive(true);
            } else {
                if (chunk.CoroutinesRunning == 0) {
                    chunk.gameObject.SetActive(false);
                }
            }

            // utopia
            if (activeChunk && t_chunckUpdateTime >= chunckUpdateTime && chunk.CoroutinesRunning == 0) {
                StartCoroutine(chunk.RefreshMap());
            }
        }

        if (t_chunckUpdateTime >= chunckUpdateTime) {
            Chunk chunk = TryGetChunk(ppos);
            if (chunk != null) {
                StartCoroutine(chunk.RefreshMap());
            }
            t_chunckUpdateTime = 0.0f;
        }

        for (float x = ppos.x - playerFOV.x; x < ppos.x + playerFOV.x; x += chunkSize.x) {
            for (float z = ppos.z - playerFOV.y; z < ppos.z + playerFOV.y; z += chunkSize.z) {
                Vector3 idxpos = new Vector3(x, 0, z);

                Chunk chunk = TryGetChunk(idxpos);
                CloudsChunk cloudsChunk = TryGetCloudsChunk(idxpos);

                if (chunk == null) {
                    int xGridCoord = Mathf.FloorToInt(x / chunkSize.x) * chunkSize.x;
                    int zGridCoord = Mathf.FloorToInt(z / chunkSize.z) * chunkSize.z;

                    var instance = Instantiate(chunkPrefab, new Vector3(xGridCoord, 0, zGridCoord), Quaternion.idenreplacedy).GetComponent<Chunk>();

                    instance.transform.SetParent(transform);
                    chunkMap.Add(instance);
                }

                if (cloudsChunk == null) {
                    int xGridCoord = Mathf.FloorToInt(x / chunkSize.x) * chunkSize.x;
                    int zGridCoord = Mathf.FloorToInt(z / chunkSize.z) * chunkSize.z;

                    var instance = Instantiate(cloudsChunkPrefab, new Vector3(xGridCoord, cloudsHeight, zGridCoord), Quaternion.idenreplacedy).GetComponent<CloudsChunk>();

                    instance.transform.SetParent(transform);
                    cloudsChunkMap.Add(instance);
                }
            }
        }
    }

19 View Source File : WalledMapMaker.cs
License : MIT License
Project Creator : Donut-Studios

void placeNpcs()
    {
        // go through each of the NPCs attached to the script and randomly instantiate them
        foreach (GameObject npc in npcs)
        {
            float xbound = (mapWidth - 1) * tileSize;
            float ybound = (mapHeight - 1) * tileSize;
            Instantiate(npc, new Vector3(Random.Range(tileSize, xbound), 0f,
                Random.Range(tileSize, ybound)), Random.rotation);
        }
    }

19 View Source File : WalledMapMaker.cs
License : MIT License
Project Creator : Donut-Studios

void Start()
    {
        // initialize variables
        if (tileSize == 0f) tileSize = 3.2f;  // replacedume this size if none given
        mapCenter = new Vector3(mapWidth * tileSize / 2, 0.25f, mapHeight * tileSize / 2);

        // call functions to lay out a 2D array representation of the map, 
        // instantiate the environment
        layoutMap();
        fillMap();
        fillEdges();

        // with the scene complete, put in NPCs
        placeNpcs();

        // place the player at the center of the room and add the crosshairs to the screen
        Vector3 playerStart = new Vector3(tileSize, player.transform.position.y, tileSize);
        Instantiate(player, playerStart, Quaternion.Euler(new Vector3(0f, 45f)));
        Instantiate(reticle);
    }

19 View Source File : BallMover.cs
License : MIT License
Project Creator : codeyuan666

void CreateMoveBall( Vector3 explodePosition)
	{
		collBallGO = Instantiate (collBallPrefab, explodePosition, Quaternion.idenreplacedy);
	}

19 View Source File : AttackScript.cs
License : MIT License
Project Creator : HDNua

protected virtual GameObject MakeHitParticle(bool right, Vector3 position)
    {
        GameObject hitParticle = Instantiate
            (_HitParticle, position, transform.rotation)
            as GameObject;

        // 버스터 속도의 반대쪽으로 적절히 x 반전합니다.
        if (right)
        {
            Vector3 newScale = hitParticle.transform.localScale;
            newScale.x *= -1;
            hitParticle.transform.localScale = newScale;
        }

        // 효과음을 재생합니다.
        EffectScript hitEffect = hitParticle.GetComponent<EffectScript>();
        hitEffect.PlayEffectSound(SoundEffects[1].clip);

        // 생성한 효과 객체를 반환합니다.
        return hitParticle;
    }

19 View Source File : InsertSynapse.cs
License : MIT License
Project Creator : BelkinAndrey

public void SynapseInsert(GameObject parentNeuron, GameObject targetNeuron) 
    { 
        if ((prefabSynapse != null) && (targetNeuron != null) && (parentNeuron != null) && (targetNeuron != parentNeuron))
        {
            GameObject clone = Instantiate(prefabSynapse, transform.position, transform.rotation) as GameObject;
            clone.name = "Synapse";
            clone.GetComponent<InspectorSynapse>().synapse = GetComponent<SpaceNeuron>().CreateSynapse(parentNeuron.GetComponent<InspectorNeuron>().isNeuron, targetNeuron.GetComponent<InspectorNeuron>().isNeuron);
            clone.transform.parent = parentNeuron.transform;
            clone.GetComponent<InspectorSynapse>().ReLocation(parentNeuron, targetNeuron);
            //parentNeuron.GetComponent<InspectorNeuron>().isNeuron.PreSynapses.Add(clone.GetComponent<InspectorSynapse>().synapse);
            //targetNeuron.GetComponent<InspectorNeuron>().isNeuron.PostSynapses.Add(clone.GetComponent<InspectorSynapse>().synapse);
            clone.GetComponent<InspectorSynapse>().synapse.onDelete += clone.GetComponent<InspectorSynapse>().Delete;
            clone.GetComponent<InspectorSynapse>().synapse.startSignal += clone.GetComponent<InspectorSynapse>().StartSignal;
            clone.GetComponent<InspectorSynapse>().synapse.endSignal += clone.GetComponent<InspectorSynapse>().EndSignal;
        }
    }

19 View Source File : ContentHandler.cs
License : MIT License
Project Creator : Hello-Meow

public Object Instantiate(UnityEngine.Object original, Vector3 position, Quaternion rotation)
        {
            var obj = UnityEngine.Object.Instantiate(original, position, rotation);

            InitializeObject(obj);

            return obj;
        }

19 View Source File : ArrowHand.cs
License : MIT License
Project Creator : dag10

private GameObject InstantiateArrow()
		{
			GameObject arrow = Instantiate( arrowPrefab, arrowNockTransform.position, arrowNockTransform.rotation ) as GameObject;
			arrow.name = "Bow Arrow";
			arrow.transform.parent = arrowNockTransform;
			Util.ResetTransform( arrow.transform );

			arrowList.Add( arrow );

			while ( arrowList.Count > maxArrowCount )
			{
				GameObject oldArrow = arrowList[0];
				arrowList.RemoveAt( 0 );
				if ( oldArrow )
				{
					Destroy( oldArrow );
				}
			}

			return arrow;
		}

19 View Source File : Explosive.cs
License : MIT License
Project Creator : joanby

private IEnumerator OnCollisionEnter(Collision col)
        {
            if (enabled)
            {
                if (col.contacts.Length > 0)
                {
                    // compare relative velocity to collision normal - so we don't explode from a fast but gentle glancing collision
                    float velocityAlongCollisionNormal =
                        Vector3.Project(col.relativeVelocity, col.contacts[0].normal).magnitude;

                    if (velocityAlongCollisionNormal > detonationImpactVelocity || m_Exploded)
                    {
                        if (!m_Exploded)
                        {
                            Instantiate(explosionPrefab, col.contacts[0].point,
                                        Quaternion.LookRotation(col.contacts[0].normal));
                            m_Exploded = true;

                            SendMessage("Immobilize");

                            if (reset)
                            {
                                m_ObjectResetter.DelayedReset(resetTimeDelay);
                            }
                        }
                    }
                }
            }

            yield return null;
        }

19 View Source File : Labels.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private static TextMesh CreateShadow(string name, int size, TextAnchor anchor, Color color, Font font, TextAlignment align, FontStyle style = FontStyle.Normal)
        {
            if (font == null)
            {
                return null;
            }

            GameObject res1 = GameObject.Find(name);
            if (res1 == null || res1.GetComponent<UILabel>() == null)
            {
                return null;
            }

            GameObject res = (GameObject)GameObject.Instantiate(res1, res1.transform.position, res1.transform.rotation);

            TextMesh text = res.GetComponent<TextMesh>();
            if (text == null)
            {
                text = res.AddComponent<TextMesh>();
            }

            MeshRenderer render = res.GetComponent<MeshRenderer>();
            if (render == null)
            {
                render = res.AddComponent<MeshRenderer>();
            }

            UILabel label = res.GetComponent<UILabel>();
            render.material = font.material;
            text.font = font;
            text.fontSize = Mathf.RoundToInt(size * Anarchy.UI.UIManager.LabelScale.Value);
            text.anchor = anchor;
            text.alignment = align;
            text.color = color;
            text.fontStyle = style;
            res.transform.SetParent(res1.transform.parent);
            res.transform.localPosition = res1.transform.localPosition;
            res.transform.localRotation = res1.transform.localRotation;
            res.transform.localScale = new Vector3(4.9f, 4.9f);
            Transform tf = text.transform;
            float deltaX = 1.25f;
            if (anchor == TextAnchor.MiddleRight || anchor == TextAnchor.UpperRight || anchor == TextAnchor.LowerRight)
            {
                deltaX = -deltaX;
            }
            float deltaY = 1.25f;
            if ((int)anchor >= 6)
            {
                deltaY = -deltaY;
            }

            deltaY *= Anarchy.UI.UIManager.LabelScale.Value;
            deltaX *= Anarchy.UI.UIManager.LabelScale.Value;
            tf.localPosition = new Vector3(tf.localPosition.x + deltaX, tf.localPosition.y - deltaY, tf.localPosition.z + 0.00001f);

            if (label != null)
            {
                text.text = label.text;
                label.enabled = false;
            }
            res.layer = 5;
            text.richText = true;
            text.gameObject.name = name + "(Shadow)";
            return text;
        }

19 View Source File : InvAttachmentPoint.cs
License : MIT License
Project Creator : mamoniem

public GameObject Attach (GameObject prefab)
	{
		if (mPrefab != prefab)
		{
			mPrefab = prefab;

			// Remove the previous child
			if (mChild != null) Destroy(mChild);

			// If we have something to create, let's do so now
			if (mPrefab != null)
			{
				// Create a new instance of the game object
				Transform t = transform;
				mChild = Instantiate(mPrefab, t.position, t.rotation) as GameObject;

				// Parent the child to this object
				Transform ct = mChild.transform;
				ct.parent = t;

				// Reset the pos/rot/scale, just in case
				ct.localPosition = Vector3.zero;
				ct.localRotation = Quaternion.idenreplacedy;
				ct.localScale = Vector3.one;
			}
		}
		return mChild;
	}

19 View Source File : RandomMapMaker.cs
License : MIT License
Project Creator : Donut-Studios

void Start()
    {
        // initialize variables
        if (tileSize == 0f) tileSize = 3.2f;  // replacedume this size if none given
        mapCenter = new Vector3(mapWidth * tileSize / 2, 1f, mapHeight * tileSize / 2);

        // call functions to lay out a 2D array representation of the map, 
        // instantiate the environment
        layoutMap();
        fillMap();
		fillEdges();

        // with the scene complete, put in NPCs
        placeNpcs();

        // place the player at the center of the room and add the crosshairs to the screen
        Instantiate(player, mapCenter, Quaternion.idenreplacedy);
        Instantiate(reticle);
    }

19 View Source File : RandomMapMaker.cs
License : MIT License
Project Creator : Donut-Studios

void fillMap()
    {
        // go through arrays and place floor/items as they're written
        // adjust position according to i, j multiplied by the tileSize
        for (int i = 0; i < mapWidth; i++)
            for (int j = 0; j < mapHeight; j++)
            {
                // get prefabs to be placed
                GameObject floorObj = mapFloor[i, j];
                GameObject groundItemObj = mapItems[i, j];
                GameObject inAirItemObj = mapInAirItems[i, j];

                // create floor instances and space according to tile size
                Instantiate(floorObj, new Vector3(i * tileSize, 0.0f, j * tileSize), 
                    Quaternion.idenreplacedy);

                // place ground items if they're not null - scale and position properly
                if (groundItemObj != null)
                {
                    float scale = Random.Range(minScaling, maxScaling);
                    Vector3 scaling = new Vector3(scale, scale, scale);
					GameObject t = Instantiate(groundItemObj, 
                        new Vector3(i * tileSize, groundItemObj.transform.position.y, j * tileSize),
                        Quaternion.idenreplacedy);
                    t.transform.localScale += scaling;
                }

                // place in air items if not null
                if (inAirItemObj != null)
                    Instantiate(inAirItemObj, new Vector3(i * tileSize, 
                        yOffset + inAirItemObj.transform.position.y, j * tileSize), 
                        Quaternion.idenreplacedy);
            }
    }

19 View Source File : InsertOneNeuron.cs
License : MIT License
Project Creator : BelkinAndrey

public void InsertNeuron() 
    {
        if ((_panel != null) && (_neurons != null) && (prefabNeuron != null)) 
        {
            Vector3 PositionPanel = Camera.main.ScreenToWorldPoint(_panel.transform.position);
            PositionPanel.z = 0f;
            GameObject clone = Instantiate(prefabNeuron, PositionPanel, transform.rotation) as GameObject;
            clone.name = "Neuron";
            if (_neurons.transform.childCount < InsertLayer) NewLauers();
            clone.transform.parent = _neurons.transform.GetChild(InsertLayer);
            clone.GetComponent<InspectorNeuron>().isNeuron = GetComponent<SpaceNeuron>().CreateNeuron(new Vector2(clone.transform.position.x, clone.transform.position.y), InsertLayer, InsertType);
            clone.GetComponent<InspectorNeuron>().reColor();
            clone.GetComponent<InspectorNeuron>().isNeuron.onAction += clone.GetComponent<InspectorNeuron>().OnActionNeuron;
            clone.GetComponent<InspectorNeuron>().isNeuron.deAction += clone.GetComponent<InspectorNeuron>().deActionNeuron;
            if (InsertType == 2) (clone.GetComponent<InspectorNeuron>().isNeuron.summator as SummatordIN).DeReActionNeuron += clone.GetComponent<InspectorNeuron>().DeReActionNeuron; 
        }
    }

19 View Source File : RandomMapMaker.cs
License : MIT License
Project Creator : Donut-Studios

void placeNpcs()
    {
        // go through each of the NPCs attached to the script and randomly instantiate them
        foreach (GameObject npc in npcs)
        {
            float xbound = (mapWidth - 1) * tileSize;
            float ybound = (mapHeight - 1) * tileSize;
            Instantiate(npc, new Vector3(Random.Range(0f, xbound), 0f, 
                Random.Range(0f, ybound)), Quaternion.idenreplacedy);
        }
    }

19 View Source File : World.cs
License : MIT License
Project Creator : BrunoS3D

public void InsertGravityBlockAt(int x, int y, int z, int block) {
        Vector3 mid = new Vector3(0.5f, 0.5f, 0.5f);

        var instance = Instantiate(gravityBlockPrefab, new Vector3(x, y, z) + mid, Quaternion.idenreplacedy);
        var gravityBlock = instance.GetComponent<GravityBlock>();

        gravityBlock.Setup(block);
    }

19 View Source File : WalledMapMaker.cs
License : MIT License
Project Creator : Donut-Studios

void fillEdges()
    {
        // fill in edges along the width
        for (int i = 0; i < mapWidth; i++)
        {
            Instantiate(wallXHigh, new Vector3((i + 0.5f) * tileSize, 
                wallXHigh.transform.position.y, 0.5f * tileSize), Quaternion.idenreplacedy);
            Instantiate(wallXHigh, new Vector3((i + 0.5f) * tileSize,
                wallXHigh.transform.position.y, (mapHeight - 0.5f) * tileSize), Quaternion.idenreplacedy);
        }

        // fill in edges along the height
        for (int j = 0; j < mapHeight; j++)
        {
            Instantiate(wallZHigh, new Vector3(0.5f * tileSize,
                wallZHigh.transform.position.y, (j + 0.5f) * tileSize), Quaternion.idenreplacedy);
            Instantiate(wallZHigh, new Vector3((mapWidth - 0.5f) * tileSize,
                wallZHigh.transform.position.y, (j + 0.5f) * tileSize), Quaternion.idenreplacedy);
        }
    }

19 View Source File : WalledMapMaker.cs
License : MIT License
Project Creator : Donut-Studios

void fillMap()
    {
        // go through arrays and place floors and walls as they're written
        // adjust position according to i, j multiplied by the tileSize
        for (int i = 0; i < mapWidth; i++)
            for (int j = 0; j < mapHeight; j++)
            {
                // get prefabs to be placed
                GameObject floorObj = mapFloor[i, j];
                GameObject wallObj = mapWalls[i, j];

                // create floor instances and space according to tile size
                Instantiate(floorObj, new Vector3((i + 0.5f) * tileSize, 0.0f, (j + 0.5f) * tileSize),
                    Quaternion.idenreplacedy);

                // place walls
                if (wallObj != null)
                    Instantiate(wallObj, new Vector3((i + 0.5f) * tileSize, wallObj.transform.position.y, 
                        (j + 0.5f) * tileSize), Quaternion.idenreplacedy);
            }
    }

19 View Source File : UnityARUserAnchorExample.cs
License : MIT License
Project Creator : codeyuan666

void Update () {
		if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
		{
			GameObject clone = Instantiate(prefabObject, Camera.main.transform.position + (this.distanceFromCamera * Camera.main.transform.forward), Quaternion.idenreplacedy);
			UnityARUserAnchorComponent component = clone.GetComponent<UnityARUserAnchorComponent>();
			m_Clones.Add(component.AnchorId);
			m_TimeUntilRemove = 4.0f;
		}

		// just remove anchors afte a certain amount of time for example's sake.
		m_TimeUntilRemove -= Time.deltaTime;
		if (m_TimeUntilRemove <= 0.0f)
		{
            foreach (string id in m_Clones)
            {
                Console.WriteLine("Removing anchor with id: " + id);
                UnityARSessionNativeInterface.GetARSessionNativeInterface().RemoveUserAnchor(id);
                break;
            }
            m_TimeUntilRemove = 4.0f;
		}
	}

19 View Source File : RandomMapMaker.cs
License : MIT License
Project Creator : Donut-Studios

void Start()
    {
        // initialize variables
        if (tileSize == 0f) tileSize = 3.2f;  // replacedume this size if none given
        mapCenter = new Vector3(mapWidth * tileSize / 2, 1f, mapHeight * tileSize / 2);

        // call functions to lay out a 2D array representation of the map, 
        // instantiate the environment
        layoutMap();
        fillMap();

        // with the scene complete, put in NPCs
        placeNpcs();

        // place the player at the center of the room and add the crosshairs to the screen
        Instantiate(player, mapCenter, Quaternion.idenreplacedy);
        Instantiate(reticle);
    }

19 View Source File : InsertOneNeuron.cs
License : MIT License
Project Creator : BelkinAndrey

public InspectorNeuron LoadNeuron(Vector2 position, int layer, int type) 
    {
        InspectorNeuron Inspector = null;
        if ((_panel != null) && (_neurons != null) && (prefabNeuron != null))
        {
            GameObject clone = Instantiate(prefabNeuron, position, transform.rotation) as GameObject;
            clone.name = "Neuron";
            if (_neurons.transform.childCount < InsertLayer) NewLauers();
            clone.transform.parent = _neurons.transform.GetChild(InsertLayer);
            clone.GetComponent<InspectorNeuron>().isNeuron = GetComponent<SpaceNeuron>().CreateNeuron(new Vector2(position.x, position.y), layer, type);
            clone.GetComponent<InspectorNeuron>().reColor();
            clone.GetComponent<InspectorNeuron>().isNeuron.onAction += clone.GetComponent<InspectorNeuron>().OnActionNeuron;
            clone.GetComponent<InspectorNeuron>().isNeuron.deAction += clone.GetComponent<InspectorNeuron>().deActionNeuron;
            if (type == 2) (clone.GetComponent<InspectorNeuron>().isNeuron.summator as SummatordIN).DeReActionNeuron += clone.GetComponent<InspectorNeuron>().DeReActionNeuron;
            Inspector = clone.GetComponent<InspectorNeuron>();
        }
        return Inspector;
    }

19 View Source File : AttackScript.cs
License : MIT License
Project Creator : HDNua

protected virtual GameObject MakeHitParticle(bool right, Transform transform)
    {
        GameObject hitParticle = Instantiate
            (_HitParticle, transform.position, transform.rotation)
            as GameObject;

        // 버스터 속도의 반대쪽으로 적절히 x 반전합니다.
        if (right)
        {
            Vector3 newScale = hitParticle.transform.localScale;
            newScale.x *= -1;
            hitParticle.transform.localScale = newScale;
        }

        // 효과음을 재생합니다.
        EffectScript hitEffect = hitParticle.GetComponent<EffectScript>();
        hitEffect.PlayEffectSound(SoundEffects[1].clip);

        // 생성한 효과 객체를 반환합니다.
        return hitParticle;
    }

19 View Source File : BallMaker.cs
License : MIT License
Project Creator : codeyuan666

void CreateBall(Vector3 atPosition)
	{
		GameObject ballGO = Instantiate (ballPrefab, atPosition, Quaternion.idenreplacedy);
			
		
		float r = Random.Range(0.0f, 1.0f);
		float g = Random.Range(0.0f, 1.0f);
		float b = Random.Range(0.0f, 1.0f);

		props.SetColor("_InstanceColor", new Color(r, g, b));

		MeshRenderer renderer = ballGO.GetComponent<MeshRenderer>();
		renderer.SetPropertyBlock(props);

	}

19 View Source File : AttackScript.cs
License : MIT License
Project Creator : HDNua

protected GameObject MakeReflectedParticle(bool right, Transform transform)
    {
        GameObject particle = Instantiate
            (_ReflectedParticle, transform.position, transform.rotation)
            as GameObject;

        // 버스터 속도의 반대쪽으로 적절히 x 반전합니다.
        if (right)
        {
            Vector3 newScale = particle.transform.localScale;
            newScale.x *= -1;
            particle.transform.localScale = newScale;
        }

        // 효과음을 재생합니다.
        EffectScript hitEffect = particle.GetComponent<EffectScript>();
        hitEffect.PlayEffectSound(SoundEffects[0].clip);

        // 생성한 효과 객체를 반환합니다.
        return particle;
    }

19 View Source File : Pool.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public static GameObject NetworkInstantiate(string name, Vector3 position, Quaternion rotation, int instantioationId, int[] viewIDs, short prefix = 0, int group = 0, object[] data = null)
        {
            GameObject res = (name.StartsWith("RCreplacedet/") ? CacheResources.RCLoad(name) : CacheResources.Load(name)) as GameObject;
            if (res == null)
            {
                Debug.LogError($"Pool.NetworkInstantiate(): Cannot fint prefab with name \"{name}\".");
                return null;
            }
            PhotonView[] views = res.GetPhotonViewsInChildren();
            if (views.Length != viewIDs.Length)
            {
                throw new System.Exception($"Pool.NetworkInstantiate(): Error in Instantiation(\"{name}\")! The resource's PhotonView count is not the same as in incoming data. {views.Length} != {viewIDs.Length}");
            }
            for (int i = 0; i < views.Length; i++)
            {
                views[i].viewID = viewIDs[i];
                views[i].prefix = prefix;
                views[i].instantiationId = instantioationId;
            }
            PhotonNetwork.networkingPeer.StoreInstantiationData(instantioationId, data);
            GameObject go = (GameObject)Object.Instantiate(res, position, rotation);
            for (int i = 0; i < views.Length; i++)
            {
                views[i].viewID = 0;
                views[i].prefix = -1;
                views[i].instantiationId = -1;
                views[i].prefixBackup = -1;
            }
            PhotonNetwork.networkingPeer.RemoveInstantiationData(instantioationId);
            if (PhotonNetwork.networkingPeer.instantiatedObjects.ContainsKey(instantioationId))
            {
                GameObject gameobj = PhotonNetwork.networkingPeer.instantiatedObjects[instantioationId];
                string str2 = string.Empty;
                if (gameobj != null)
                {
                    foreach (PhotonView view in gameobj.GetPhotonViewsInChildren())
                    {
                        if (view != null)
                        {
                            str2 = str2 + view.ToString() + ", ";
                        }
                    }
                }
                object[] args = new object[] { gameobj, instantioationId, PhotonNetwork.networkingPeer.instantiatedObjects.Count, go, str2, PhotonNetwork.lastUsedViewSubId, PhotonNetwork.lastUsedViewSubIdStatic, NetworkingPeer.photonViewList.Count };
                Debug.LogError(string.Format("DoInstantiate re-defines a GameObject. Destroying old entry! New: '{0}' (instantiationID: {1}) Old: {3}. PhotonViews on old: {4}. instantiatedObjects.Count: {2}. PhotonNetwork.lastUsedViewSubId: {5} PhotonNetwork.lastUsedViewSubIdStatic: {6} photonViewList.Count {7}.)", args));
                PhotonNetwork.networkingPeer.RemoveInstantiatedGO(go, true);
            }
            PhotonNetwork.networkingPeer.instantiatedObjects.Add(instantioationId, go);
            return go;
        }

19 View Source File : DeadEffectScript.cs
License : MIT License
Project Creator : HDNua

GameObject MakeParticle(GameObject type, Vector2 dir, float speed)
    {
        GameObject particle = Instantiate
            (type, transform.position, transform.rotation)
            as GameObject;
        particle.GetComponent<Rigidbody2D>().velocity = dir.normalized * speed;
        return particle;
    }

19 View Source File : ControllerButtonHints.cs
License : MIT License
Project Creator : dag10

private void CreateAndAddButtonInfo( EVRButtonId buttonID )
		{
			Transform buttonTransform = null;
			List<MeshRenderer> buttonRenderers = new List<MeshRenderer>();

			string buttonDebug = "Looking for button: " + buttonID;

			EVRButtonId searchButtonID = buttonID;
			if ( buttonID == EVRButtonId.k_EButton_Grip && SteamVR.instance.hmd_TrackingSystemName.ToLowerInvariant().Contains( "oculus" ) )
			{
				searchButtonID = EVRButtonId.k_EButton_Axis2;
			}
			ulong buttonMaskForID = ( 1ul << (int)searchButtonID );

			foreach ( KeyValuePair<string, ulong> componentButtonMask in componentButtonMasks )
			{
				if ( ( componentButtonMask.Value & buttonMaskForID ) == buttonMaskForID )
				{
					buttonDebug += "\nFound component: " + componentButtonMask.Key + " " + componentButtonMask.Value;
					Transform componentTransform = renderModel.FindComponent( componentButtonMask.Key );

					buttonTransform = componentTransform;

					buttonDebug += "\nFound componentTransform: " + componentTransform + " buttonTransform: " + buttonTransform;

					buttonRenderers.AddRange( componentTransform.GetComponentsInChildren<MeshRenderer>() );
				}
			}

			buttonDebug += "\nFound " + buttonRenderers.Count + " renderers for " + buttonID;
			foreach ( MeshRenderer renderer in buttonRenderers )
			{
				buttonDebug += "\n\t" + renderer.name;
			}

			HintDebugLog( buttonDebug );

			if ( buttonTransform == null )
			{
				HintDebugLog( "Couldn't find buttonTransform for " + buttonID );
				return;
			}

			ButtonHintInfo hintInfo = new ButtonHintInfo();
			buttonHintInfos.Add( buttonID, hintInfo );

			hintInfo.componentName = buttonTransform.name;
			hintInfo.renderers = buttonRenderers;

			//Get the local transform for the button
			hintInfo.localTransform = buttonTransform.Find( SteamVR_RenderModel.k_localTransformName );

			OffsetType offsetType = OffsetType.Right;
			switch ( buttonID )
			{
				case EVRButtonId.k_EButton_SteamVR_Trigger:
					{
						offsetType = OffsetType.Right;
					}
					break;
				case EVRButtonId.k_EButton_ApplicationMenu:
					{
						offsetType = OffsetType.Right;
					}
					break;
				case EVRButtonId.k_EButton_System:
					{
						offsetType = OffsetType.Right;
					}
					break;
				case Valve.VR.EVRButtonId.k_EButton_Grip:
					{
						offsetType = OffsetType.Forward;
					}
					break;
				case Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad:
					{
						offsetType = OffsetType.Up;
					}
					break;
			}

			//Offset for the text end transform
			switch ( offsetType )
			{
				case OffsetType.Forward:
					hintInfo.textEndOffsetDir = hintInfo.localTransform.forward;
					break;
				case OffsetType.Back:
					hintInfo.textEndOffsetDir = -hintInfo.localTransform.forward;
					break;
				case OffsetType.Right:
					hintInfo.textEndOffsetDir = hintInfo.localTransform.right;
					break;
				case OffsetType.Up:
					hintInfo.textEndOffsetDir = hintInfo.localTransform.up;
					break;
			}

			//Create the text hint object
			Vector3 hintStartPos = hintInfo.localTransform.position + ( hintInfo.localTransform.forward * 0.01f );
			hintInfo.textHintObject = GameObject.Instantiate( textHintPrefab, hintStartPos, Quaternion.idenreplacedy ) as GameObject;
			hintInfo.textHintObject.name = "Hint_" + hintInfo.componentName + "_Start";
			hintInfo.textHintObject.transform.SetParent( textHintParent );

			//Get all the relevant child objects
			hintInfo.textStartAnchor = hintInfo.textHintObject.transform.Find( "Start" );
			hintInfo.textEndAnchor = hintInfo.textHintObject.transform.Find( "End" );
			hintInfo.canvasOffset = hintInfo.textHintObject.transform.Find( "CanvasOffset" );
			hintInfo.line = hintInfo.textHintObject.transform.Find( "Line" ).GetComponent<LineRenderer>();
			hintInfo.textCanvas = hintInfo.textHintObject.GetComponentInChildren<Canvas>();
			hintInfo.text = hintInfo.textCanvas.GetComponentInChildren<Text>();
			hintInfo.textMesh = hintInfo.textCanvas.GetComponentInChildren<TextMesh>();

			hintInfo.textHintObject.SetActive( false );

			hintInfo.textStartAnchor.position = hintStartPos;

			if ( hintInfo.text != null )
			{
				hintInfo.text.text = hintInfo.componentName;
			}

			if ( hintInfo.textMesh != null )
			{
				hintInfo.textMesh.text = hintInfo.componentName;
			}

			centerPosition += hintInfo.textStartAnchor.position;

			// Scale hint components to match player size
			hintInfo.textCanvas.transform.localScale = Vector3.Scale( hintInfo.textCanvas.transform.localScale, player.transform.localScale );
			hintInfo.textStartAnchor.transform.localScale = Vector3.Scale( hintInfo.textStartAnchor.transform.localScale, player.transform.localScale );
			hintInfo.textEndAnchor.transform.localScale = Vector3.Scale( hintInfo.textEndAnchor.transform.localScale, player.transform.localScale );
			hintInfo.line.transform.localScale = Vector3.Scale( hintInfo.line.transform.localScale, player.transform.localScale );
		}

19 View Source File : ExplosionFireAndDebris.cs
License : MIT License
Project Creator : joanby

private IEnumerator Start()
        {
            float multiplier = GetComponent<ParticleSystemMultiplier>().multiplier;

            for (int n = 0; n < numDebrisPieces*multiplier; ++n)
            {
                var prefab = debrisPrefabs[Random.Range(0, debrisPrefabs.Length)];
                Vector3 pos = transform.position + Random.insideUnitSphere*3*multiplier;
                Quaternion rot = Random.rotation;
                Instantiate(prefab, pos, rot);
            }

            // wait one frame so these new objects can be picked up in the overlapsphere function
            yield return null;

            float r = 10*multiplier;
            var cols = Physics.OverlapSphere(transform.position, r);
            foreach (var col in cols)
            {
                if (numFires > 0)
                {
                    RaycastHit fireHit;
                    Ray fireRay = new Ray(transform.position, col.transform.position - transform.position);
                    if (col.Raycast(fireRay, out fireHit, r))
                    {
                        AddFire(col.transform, fireHit.point, fireHit.normal);
                        numFires--;
                    }
                }
            }

            float testR = 0;
            while (numFires > 0 && testR < r)
            {
                RaycastHit fireHit;
                Ray fireRay = new Ray(transform.position + Vector3.up, Random.onUnitSphere);
                if (Physics.Raycast(fireRay, out fireHit, testR))
                {
                    AddFire(null, fireHit.point, fireHit.normal);
                    numFires--;
                }
                testR += r*.1f;
            }
        }

19 View Source File : aquariumManager.cs
License : MIT License
Project Creator : BelkinAndrey

[ContextMenu("CreateCubes")]
    private void GreateCubes() 
    {
        if (prefabBox != null)
        {
            for (int ix = 0; ix < X; ix++)
            {
                for (int iy = 0; iy < Y; iy++)
                {
                    Vector3 pos = transform.position + new Vector3((iy * 40) + 20, (ix * 40) + 20, 0);
                    GameObject clone = Instantiate(prefabBox, pos, transform.rotation) as GameObject;
                    clone.name = "Segment_" + ix + "_" + iy;
                    if (clone.GetComponent<Segment>()) clone.GetComponent<Segment>().trigger = trigger;
                    clone.transform.parent = transform;
                }
            }
        }
    }

19 View Source File : SpawnEnemies.cs
License : MIT License
Project Creator : joanby

void Spawn(){

		if (origin == null)
			return;


		Vector3 spawnPosition = origin.position + Random.onUnitSphere * maxRadius;
		spawnPosition = new Vector3 (spawnPosition.x, 0.0f, spawnPosition.z);
		Instantiate (objectToSpawn, spawnPosition, Quaternion.idenreplacedy);
	}

19 View Source File : Balloon.cs
License : MIT License
Project Creator : dag10

private void SpawnParticles( GameObject particlePrefab, SoundPlayOneshot sound )
		{
			// Don't do this twice
			if ( bParticlesSpawned )
			{
				return;
			}

			bParticlesSpawned = true;

			if ( particlePrefab != null )
			{
				GameObject particleObject = Instantiate( particlePrefab, transform.position, transform.rotation ) as GameObject;
				particleObject.GetComponent<ParticleSystem>().Play();
				Destroy( particleObject, 2f );
			}

			if ( sound != null )
			{
				float lastSoundDiff = Time.time - s_flLastDeathSound;
				if ( lastSoundDiff < 0.1f )
				{
					sound.volMax *= 0.25f;
					sound.volMin *= 0.25f;
				}
				sound.Play();
				s_flLastDeathSound = Time.time;
			}
		}

19 View Source File : AmmoManager.cs
License : MIT License
Project Creator : joanby

void Awake(){
		if (ammoManager != null) {
			Destroy (GetComponent<AmmoManager> ());
			return;
		}

		ammoManager = this;

		ammoArray = new GameObject[poolSize];

		for (int i = 0; i < poolSize; i++) {
			GameObject ammo = Instantiate(ammoPrefab, Vector3.zero, Quaternion.idenreplacedy) as GameObject;
			Transform objectTransform = ammo.GetComponent<Transform> ();
			objectTransform.parent = GetComponent<Transform> ();

			ammoQueue.Enqueue (objectTransform);
			ammo.SetActive (false);
			ammoArray [i] = ammo;
		
		}
	
	}

19 View Source File : BloodSplatterScript.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            this.bloodRotation.Rotate(0f, (float)this.bloodLocalRotationYOffset, 0f);
            Transform transform = UnityEngine.Object.Instantiate(this.bloodPrefab, this.bloodPosition.position, this.bloodRotation.rotation) as Transform;
            this.bloodInstances = GameObject.FindGameObjectsWithTag("blood");
            if (this.bloodInstances.Length >= this.maxAmountBloodPrefabs)
            {
                UnityEngine.Object.Destroy(this.bloodInstances[0]);
            }
        }
    }

19 View Source File : Objects.cs
License : MIT License
Project Creator : LunariStudios

public static T Clone<T>(this T obj, Vector3 position, Quaternion rotation) where T : Object {
            return Object.Instantiate(obj, position, rotation);
        }

19 View Source File : FireSource.cs
License : MIT License
Project Creator : dag10

private void StartBurning()
		{
			isBurning = true;
			ignitionTime = Time.time;

			// Play the fire ignition sound if there is one
			if ( ignitionSound != null )
			{
				ignitionSound.Play();
			}

			if ( customParticles != null )
			{
				customParticles.Play();
			}
			else
			{
				if ( fireParticlePrefab != null )
				{
					fireObject = Instantiate( fireParticlePrefab, transform.position, transform.rotation ) as GameObject;
					fireObject.transform.parent = transform;
				}
			}
		}

19 View Source File : World.cs
License : MIT License
Project Creator : BrunoS3D

void Start() {
        player = GameObject.FindGameObjectWithTag("Player").transform;
        Vector3 ppos = player.position;

        if (randomNoise) {
            noiseScale = Random.Range(32, 128);
            noiseOffset = Random.insideUnitSphere * noiseScale * noiseScale;
        }

        for (float x = ppos.x - playerFOV.x * initialFOVMultiplier; x < ppos.x + playerFOV.x * initialFOVMultiplier; x += chunkSize.x) {
            for (float z = ppos.z - playerFOV.y * initialFOVMultiplier; z < ppos.z + playerFOV.y * initialFOVMultiplier; z += chunkSize.z) {
                int xGridCoord = Mathf.FloorToInt(x / chunkSize.x) * chunkSize.x;
                int zGridCoord = Mathf.FloorToInt(z / chunkSize.z) * chunkSize.z;

                var terrainInstance = Instantiate(chunkPrefab, new Vector3(xGridCoord, 0, zGridCoord), Quaternion.idenreplacedy);
                var cloudInstance = Instantiate(cloudsChunkPrefab, new Vector3(xGridCoord, cloudsHeight, zGridCoord), Quaternion.idenreplacedy);

                terrainInstance.transform.SetParent(transform);
                cloudInstance.transform.SetParent(transform);

                chunkMap.Add(terrainInstance.GetComponent<Chunk>());
                cloudsChunkMap.Add(cloudInstance.GetComponent<CloudsChunk>());
            }
        }
    }

19 View Source File : EventDI.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public bool Handle()
        {
            GameObject res = key.StartsWith("RCreplacedet/") ? CacheResources.RCLoad(key) : (GameObject)CacheResources.Load(key);
            if (res == null)
            {
                return false;
            }

            PhotonView[] photonViewsInChildren = res.GetPhotonViewsInChildren();
            if (photonViewsInChildren.Length != instIDs.Length)
            {
                throw new System.Exception("Error in Instantiation! The resource's PhotonView count is not the same as in incoming data.");
            }
            for (int i = 0; i < instIDs.Length; i++)
            {
                photonViewsInChildren[i].viewID = instIDs[i];
                photonViewsInChildren[i].prefix = prefix;
                photonViewsInChildren[i].instantiationId = instID;
            }
            PhotonNetwork.networkingPeer.StoreInstantiationData(instID, data);
            GameObject obj2 = (GameObject)UnityEngine.Object.Instantiate(res, position, rotation);
            for (int j = 0; j < instIDs.Length; j++)
            {
                photonViewsInChildren[j].viewID = 0;
                photonViewsInChildren[j].prefix = -1;
                photonViewsInChildren[j].prefixBackup = -1;
                photonViewsInChildren[j].instantiationId = -1;
            }
            PhotonNetwork.networkingPeer.RemoveInstantiationData(instID);
            if (PhotonNetwork.networkingPeer.instantiatedObjects.ContainsKey(instID))
            {
                GameObject go = PhotonNetwork.networkingPeer.instantiatedObjects[instID];
                string str2 = string.Empty;
                if (go != null)
                {
                    foreach (PhotonView view in go.GetPhotonViewsInChildren())
                    {
                        if (view != null)
                        {
                            str2 = str2 + view.ToString() + ", ";
                        }
                    }
                }
                object[] args = new object[] { obj2, instID, PhotonNetwork.networkingPeer.instantiatedObjects.Count, go, str2, PhotonNetwork.lastUsedViewSubId, PhotonNetwork.lastUsedViewSubIdStatic, NetworkingPeer.photonViewList.Count };
                Debug.LogError(string.Format("DoInstantiate re-defines a GameObject. Destroying old entry! New: '{0}' (instantiationID: {1}) Old: {3}. PhotonViews on old: {4}. instantiatedObjects.Count: {2}. PhotonNetwork.lastUsedViewSubId: {5} PhotonNetwork.lastUsedViewSubIdStatic: {6} photonViewList.Count {7}.)", args));
                PhotonNetwork.networkingPeer.RemoveInstantiatedGO(go, true);
            }
            PhotonNetwork.networkingPeer.instantiatedObjects.Add(instID, obj2);
            obj2.SendMessage(PhotonNetworkingMessage.OnPhotonInstantiate.ToString(), new PhotonMessageInfo(sender, timeStamp, null), SendMessageOptions.DontRequireReceiver);
            return true;
        }

19 View Source File : InvAttachmentPoint.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public GameObject Attach(GameObject prefab)
    {
        if (this.mPrefab != prefab)
        {
            this.mPrefab = prefab;
            if (this.mChild != null)
            {
                UnityEngine.Object.Destroy(this.mChild);
            }
            if (this.mPrefab != null)
            {
                Transform transform = base.transform;
                this.mChild = (UnityEngine.Object.Instantiate(this.mPrefab, transform.position, transform.rotation) as GameObject);
                Transform transform2 = this.mChild.transform;
                transform2.parent = transform;
                transform2.localPosition = Vectors.zero;
                transform2.localRotation = Quaternion.idenreplacedy;
                transform2.localScale = Vectors.one;
            }
        }
        return this.mChild;
    }

19 View Source File : InsertOneNeuron.cs
License : MIT License
Project Creator : BelkinAndrey

void NewLauers() 
    {
        while (_neurons.transform.childCount <= InsertLayer) 
        {
            GameObject cloneL = Instantiate(_layer, Vector3.zero, _layer.transform.rotation) as GameObject;
            cloneL.transform.parent = _neurons.transform;
            cloneL.name = "Layer" + (_neurons.transform.childCount - 1);
        }
    }

19 View Source File : World.cs
License : MIT License
Project Creator : BrunoS3D

public void InsertBlockParticlesAt(int x, int y, int z, int block) {
        Vector3 mid = new Vector3(0.5f, 0.5f, 0.5f);

        var instance = Instantiate(particlesPrefab, new Vector3(x, y, z) + mid, Quaternion.idenreplacedy);
        var blockParticles = instance.GetComponent<BlockParticles>();

        blockParticles.Setup(block, blockDefs[block].timeToDestroyParticles);
    }

19 View Source File : ActivateTrigger.cs
License : MIT License
Project Creator : Donut-Studios

private void DoActivateTrigger()
        {
            triggerCount--;

            if (triggerCount == 0 || repeatTrigger)
            {
                Object currentTarget = target ?? gameObject;
                Behaviour targetBehaviour = currentTarget as Behaviour;
                GameObject targetGameObject = currentTarget as GameObject;
                if (targetBehaviour != null)
                {
                    targetGameObject = targetBehaviour.gameObject;
                }

                switch (action)
                {
                    case Mode.Trigger:
                        if (targetGameObject != null)
                        {
                            targetGameObject.BroadcastMessage("DoActivateTrigger");
                        }
                        break;
                    case Mode.Replace:
                        if (source != null)
                        {
                            if (targetGameObject != null)
                            {
                                Instantiate(source, targetGameObject.transform.position,
                                            targetGameObject.transform.rotation);
                                DestroyObject(targetGameObject);
                            }
                        }
                        break;
                    case Mode.Activate:
                        if (targetGameObject != null)
                        {
                            targetGameObject.SetActive(true);
                        }
                        break;
                    case Mode.Enable:
                        if (targetBehaviour != null)
                        {
                            targetBehaviour.enabled = true;
                        }
                        break;
                    case Mode.Animate:
                        if (targetGameObject != null)
                        {
                            targetGameObject.GetComponent<Animation>().Play();
                        }
                        break;
                    case Mode.Deactivate:
                        if (targetGameObject != null)
                        {
                            targetGameObject.SetActive(false);
                        }
                        break;
                }
            }
        }

See More Examples