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


C# GameObject.GetInstanceID方法代码示例

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


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

示例1: AddMesh

    public bool AddMesh(GameObject go)
    {
        if (_lut.ContainsKey(go.GetInstanceID())) {
            return true;
        }

        // returns false if renderer is not available
        if (go.GetComponent<Renderer>() == null) {
            return false;
        }

        // returns false if not a mesh
        MeshFilter mf = (MeshFilter)go.GetComponent (typeof(MeshFilter));
        if (mf == null) {
            return false;
        }

        MeshData md = new MeshData ();
        md._instID = go.GetInstanceID ();
        md._vertCount = mf.mesh.vertexCount;
        md._triCount = mf.mesh.triangles.Length / 3;
        md._materialCount = go.GetComponent<Renderer>().sharedMaterials.Length;
        md._boundSize = go.GetComponent<Renderer>().bounds.size.magnitude;
        _lut.Add (md._instID, md);
        return true;
    }
开发者ID:zhukunqian,项目名称:usmooth,代码行数:26,代码来源:MeshLut.cs

示例2: RecycleGO

    public static bool RecycleGO(GameObject prefab,GameObject instGO)
    {
        if (msPoolsDict == null)
        {
            msPoolsDict = new Dictionary<int, Pool_GameObj>();
        }

        //�ҳ���Ӧ��PoolGameObject
        if(prefab == null)
        {
            IPoolObj poolObj = instGO.GetComponent(typeof(IPoolObj)) as IPoolObj;
            prefab = poolObj.Prefab;
            if (prefab == null)
            {
                //Debug.LogWarning("noPrefab ="+instGO.name);
                return false;
            }
         }

        Pool_GameObj poolGo = null;
        if (!msPoolsDict.TryGetValue(prefab.GetInstanceID(), out poolGo))
        {
            poolGo = new Pool_GameObj(prefab);
            msPoolsDict.Add(prefab.GetInstanceID(), poolGo);
        }
        poolGo.RecycleGO(instGO);
        return true;
    }
开发者ID:minh3d,项目名称:Fish,代码行数:28,代码来源:Pool_GameObj.cs

示例3: GetObject

    /// <summary>
    /// プールからオブジェクトを取得する
    /// </summary>
    /// <param name="prefab">プーリングしたゲームオブジェクト</param>
    /// <param name="position">セットする座標</param>
    /// <param name="rotation">セットする回転</param>
    /// <param name="parent">parentに設定するGameObjectのTransform</param>
    /// <returns>Active状態にしたゲームオブジェクト</returns>
    public GameObject GetObject(GameObject prefab, Vector3 position, Quaternion rotation, Transform parent = null)
    {
        // キーが存在しない
        if (!pooledObject.ContainsKey(prefab.GetInstanceID()))
        {
            return null;
        }

        // プールを取得
        List<GameObject> pool = pooledObject[prefab.GetInstanceID()];

        // 既に生成した分で足りている場合
        foreach (var list in pool)
        {
            if (!list.activeInHierarchy)
            {
                list.transform.position = position;
                list.transform.rotation = rotation;
                list.transform.parent = parent;
                list.SetActive(true);
                return list;
            }
        }

        // 不足していた場合
        var obj = Instantiate(prefab, position, rotation) as GameObject;
        obj.transform.parent = parent;
        pool.Add(obj);

        return obj;
    }
开发者ID:Doku0911,项目名称:TeamSotsuten,代码行数:39,代码来源:ObjectPool.cs

示例4: Request

    public GameObject Request(GameObject prefab, Transform parent, Vector3 position, Quaternion rotation)
    {
        if (id == 0) id = prefab.GetInstanceID ();

        if(id != prefab.GetInstanceID())
        {
            Debug.LogError(string.Format("Cannot create an isntance of {0} from pool {1}", prefab.name, id));
            return null;
        }

        GameObject instance;

        if(free.Count > 0)
        {
            instance = free[0];
            free.Remove(instance);
        }
        else
        {
            instance = (GameObject)GameObject.Instantiate(prefab);
        }

        PlaceObject(instance.transform, parent, position, rotation);

        used.Add(instance);
        instance.name = prefab.name;

        return instance;
    }
开发者ID:Stumpstump,项目名称:RoverGame,代码行数:29,代码来源:Pool.cs

示例5: castSpell

    public void castSpell(GameObject target)
    {
        if(target.GetComponent("Enchantable") == null)
        {
            TraceLogger.LogKVtime("attempt", getSpellName());
            TraceLogger.LogKV("target", target.GetInstanceID().ToString()+", "+target.name+", "+target.transform.position);
            TraceLogger.LogKV("player", ""+ObjectManager.FindById("Me").transform.position);
            (GameObject.Find("Popup").GetComponent("Popup") as Popup).popup("Target ("+target.name+") immune to magic.");
            SetHidden(false);
            return;
        }

        TraceLogger.LogKVtime("spell", getSpellName());
        ProgramLogger.LogKVtime("spell", getSpellName());
        TraceLogger.LogKV("target", target.GetInstanceID().ToString()+", "+target.name+", "+target.transform.position);
        TraceLogger.LogKV("player", ""+ObjectManager.FindById("Me").transform.position);

        June june = new June(target, file_name);

        SetHidden(false);

        item_name = "Blank";
        file_name = "";
        animate = false;

        inventoryTexture = Resources.Load( "Textures/Scroll") as Texture2D;

        (target.GetComponent("Enchantable") as Enchantable).enchant(june, delegate(GameObject t){absorbSpell(t); });
    }
开发者ID:johnalvn,项目名称:CodeSpells,代码行数:29,代码来源:CodeScrollItem.cs

示例6: PoolCollectionForGameObject

    public static PoolCollection PoolCollectionForGameObject(GameObject go)
    {
        if( instance._instanceIdToPoolCollection.ContainsKey(go.GetInstanceID())) {
            return instance._instanceIdToPoolCollection[go.GetInstanceID()];
        }

        return null;
    }
开发者ID:russelklab,项目名称:PoolKit,代码行数:8,代码来源:PoolMan.cs

示例7: SetObject

    /// <summary>
    /// 新しいプールを生成する
    /// </summary>
    /// <param name="prefab">プーリングするオブジェクト</param>
    /// <param name="createCount">プーリングする数</param>
    public void SetObject(GameObject prefab, int createCount)
    {
        // 連想配列にセット
        pooledObject.Add(prefab.GetInstanceID(), new List<GameObject>());

        // プーリング
        for (int i = 0; i < createCount; i++)
        {
            GameObject obj = Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;
            pooledObject[prefab.GetInstanceID()].Add(obj);
            obj.SetActive(false);
        }
    }
开发者ID:Doku0911,项目名称:TeamSotsuten,代码行数:18,代码来源:ObjectPool.cs

示例8: PrefabsWillNotGetNewIds

        public void PrefabsWillNotGetNewIds()
        {
            GameObject go = new GameObject(true);
            TestComponent cmp = new TestComponent();
            go.AddComponent(cmp);

            int oldId = go.GetInstanceID();
            int oldCmpId = cmp.GetInstanceID();
            go.SetNewId(new Dictionary<int, UnityObject>());

            Assert.That(go.GetInstanceID(), Is.EqualTo(oldId));
            Assert.That(cmp.GetInstanceID(), Is.EqualTo(oldCmpId));
        }
开发者ID:Joelone,项目名称:FFWD,代码行数:13,代码来源:WhenSettingNewIds.cs

示例9: ProducePart

    public void ProducePart( GameInfo gameInfo, GameObject myGO, int amount = 1 )
    {
        int myGOTeam = myGO.GetComponent<Generic_Team>().TeamNum;

        if (isServer)
        {
            List<GameObject> parts = new List<GameObject>();
            for ( int i = 0; i < amount; i++ )
            {
                parts.Add(MakePart( new Vector2( i, 0 ), Vector2.zero, 0.0f, myGOTeam ));
            }

            List<GameObject> myGO_parts;
            myGO_parts = myGO.GetComponent<Unit_PartPlacement>().parts;
            myGO_parts.Clear();
            int gOID = myGO.GetInstanceID();
            //u16 playerID = blob.getPlayer().getNetworkID();
            for (int i = 0; i < parts.Count; i++)
            {
                GameObject gO = parts[i];
                myGO_parts.Add( gO );
                gO.GetComponent<Part_Info>().OwnerID = gOID;
                //b.set_u16( "playerID", playerID );
                gO.GetComponent<Part_Info>().ShipID = -1; // don't push on ship
            }
        }
    }
开发者ID:Morgasm,项目名称:ironarmada,代码行数:27,代码来源:PartProduction.cs

示例10: OnLightEnter

 private void OnLightEnter(Light2D l, GameObject g)
 {
     if (g.GetInstanceID() == id){
         c += l.LightColor;
         AudioSource.PlayClipAtPoint(hitSound, transform.position, 0.1f);
     }
 }
开发者ID:Insality,项目名称:LD33,代码行数:7,代码来源:EventSample_VLS.cs

示例11: RemoveCache

 public void RemoveCache(GameObject tmp)
 {
     if (cachedItem != null && tmp != null)
         if (tmp.GetInstanceID() == cachedItem.GetInstanceID())
             tmp = null;
                
 }
开发者ID:WilliamRADFunk,项目名称:vedic,代码行数:7,代码来源:DataCache.cs

示例12: OnLightStay

 void OnLightStay(Light2D l, GameObject g)
 {
     if (g.GetInstanceID() == id)
     {
         isDetected = true;
     }
 }
开发者ID:williamd4112,项目名称:GGJ2016,代码行数:7,代码来源:EventSample_VLS.cs

示例13: RopeTubeRenderer

    public RopeTubeRenderer(GameObject _gameObject, bool useMeshOnly)
    {
        if (!useMeshOnly)
        {
            this._gameObject = _gameObject;
            this._transform = _gameObject.transform;

            // ensure necessary components //
            MeshFilter filter = _gameObject.GetComponent<MeshFilter>();
            if (filter == null) filter = _gameObject.AddComponent<MeshFilter>();
            MeshRenderer renderer = _gameObject.GetComponent<MeshRenderer>();
            if (renderer == null) renderer = _gameObject.AddComponent<MeshRenderer>();

            _mesh = new Mesh();
            _mesh.name = "RopeTube_" + _gameObject.GetInstanceID();
            _mesh.hideFlags = HideFlags.HideAndDontSave;
            filter.mesh = _mesh;

            if (renderer.sharedMaterial == null)
                renderer.sharedMaterial = (Material)Resources.Load("Materials/Rope", typeof(Material));
        }
        else
        {
            this._gameObject = _gameObject;
            this._transform = _gameObject.transform;

            _mesh = new Mesh();
            _mesh.name = "RopeTube_" + _gameObject.GetInstanceID();
            _mesh.hideFlags = HideFlags.HideAndDontSave;
        }
    }
开发者ID:etiens,项目名称:VikingQuest,代码行数:31,代码来源:RopeTubeRenderer.cs

示例14: DetectMatches

 // here is the function we call from Spawnscript
 // scan the array created by the above events
 // return a match number
 public int DetectMatches(GameObject other)
 {
     int matches = 0;
     if (!other) {
         Debug.Log("missing gameobject (other)");
         return 0;
     }
     foreach (GameObject collided in CollidingWith) {
         if (!collided) {
             Debug.Log("missing gameobject (collided)");
             continue;
         }
         if (other.GetInstanceID() == collided.GetInstanceID()) {
             Debug.Log("Avoid nasty hard loop");
             continue;
         }
         if (other.tag == collided.tag) {
             matches++;
             CurrentMatches.Add(collided);
             //CellScript cScript = collided.GetComponent<CellScript>();
             //matches += cScript.DetectMatches(collided);
             //Debug.Log("Matched: " + matches);
         }
     }
     return matches;
 }
开发者ID:CaptainChris007,项目名称:fruitgame,代码行数:29,代码来源:CellScript.cs

示例15: GetGameObject

	public GameObject GetGameObject(GameObject prefab, Vector3 position, Quaternion rotation)
	{
		// 受け取ったprefabのインスタンスIDをkeyとする
		int key = prefab.GetInstanceID ();

		// オブジェクトプールに指定のKeyなければ新しく生成する
		if (pooledGameObjects.ContainsKey (key) == false) {
			pooledGameObjects.Add(key, new List<GameObject>());
		}

		List<GameObject> gameObjects = pooledGameObjects[key];

		// ゲームオブジェクトが非アクティブなものを探す
		foreach (var tmpGO in gameObjects) {
			if(tmpGO.activeInHierarchy == false) {
				tmpGO.transform.position = position;
				tmpGO.transform.rotation = rotation;
				tmpGO.SetActive(true);
				return tmpGO;
			}
		}

		// 使用できるものがないのでゲームオブジェクトを新しく生成する
		GameObject go = (GameObject)Instantiate (prefab, position, rotation);
		go.transform.parent = this.transform;
		return go;
	}
开发者ID:kazu200095,项目名称:FPSBrawl,代码行数:27,代码来源:ObjectPool.cs


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