Beispiel #1
0
        } //END GetPrefab()


        //------------------------------------------------------//
        public static GameObject InstantiatePrefab( PrefabFactory.Prefabs prefab )
        //------------------------------------------------------//
        {

            return InstantiatePrefab( prefab, _parentTo );

        } //END InstantiatePrefab()
Beispiel #2
0
        } //END DestroyDuplicateInstance

        //------------------------------------------------------//
        public static GameObject GetPrefab( PrefabFactory.Prefabs prefab )
        //------------------------------------------------------//
        {

            return PrefabFactory.instance.PrefabsDictionary[ prefab.ToString() ];

        } //END GetPrefab()
Beispiel #3
0
        } //END GetPrefab()


        //------------------------------------------------------//
        public static GameObject GetExistingPrefab( PrefabFactory.Prefabs name )
        //------------------------------------------------------//
        {

            if( PrefabFactory.instance.ExistingPrefabs.ContainsKey( name.ToString() ) )
            {
                return PrefabFactory.instance.ExistingPrefabs[ name.ToString() ];
            }
            else
            {
                return null;
            }

        } //END GetPrefab()
Beispiel #4
0
        } //END AddToExistingPrefabsDictionary()


        //------------------------------------------------------//
        public static void DestroyExistingPrefab( PrefabFactory.Prefabs name )
        //------------------------------------------------------//
        {

            if( PrefabFactory.instance.ExistingPrefabs.ContainsKey( name.ToString() ) )
            {

                if( PrefabFactory.instance.ExistingPrefabs[ name.ToString() ] != null )
                {
                    Destroy( PrefabFactory.instance.ExistingPrefabs[ name.ToString() ] );
                    PrefabFactory.instance.ExistingPrefabs.Remove( name.ToString() );
                }

            }

        } //END DestroyExistingPrefab()
Beispiel #5
0
        } //END InstantiatePrefab()

        //------------------------------------------------------//
        public static GameObject InstantiatePrefab( PrefabFactory.Prefabs prefab, Transform addToParent )
        //------------------------------------------------------//
        {

            if( PrefabFactory.instance.PrefabsDictionary.ContainsKey( prefab.ToString() ) && PrefabFactory.instance.PrefabsDictionary[ prefab.ToString() ] != null )
            {
                if( showDebug ) { Debug.Log( "PrefabManager.cs InstantiatePrefab( " + prefab.ToString() + " )" ); }

                GameObject clone = (GameObject)Instantiate( PrefabFactory.instance.PrefabsDictionary[ prefab.ToString() ] );

                clone.name = RemoveCloneFromNameString( clone.name );

                clone.name = NameDifferentlyIfSameKeyExistsInPrefabsDictionary( clone.name );

                AddToExistingPrefabsDictionary( clone );

                if( addToParent != null )
                {
                    clone.transform.SetParent( addToParent );
                }

                return clone;
            }
            else
            {
                if( showDebug )
                {
                    Debug.Log( "InstantiatePrefab() error, unable to find " + prefab.ToString() + " in Dictionary below" );

                    foreach( KeyValuePair<string, GameObject> pair in PrefabFactory.instance.PrefabsDictionary )
                    {
                        Debug.Log( "PrefabFactory.cs ... PrefabsDictionary Key{ " + pair.Key + " } : Value{ " + pair.Value + " }" );
                    }
                }

                if( showDebug ) { Debug.Log( "Contains Key for " + prefab.ToString() + " = " + ( PrefabFactory.instance.PrefabsDictionary.ContainsKey( prefab.ToString() ) ) ); }
                if( showDebug ) { Debug.Log( "PrefabManager.cs InstantiatePrefab( " + prefab.ToString() + " ) failed to find prefab! PrefabFactory.instance =" + PrefabFactory.instance.ToString() + ", isPrefabNull = " + ( PrefabFactory.instance.PrefabsDictionary[ prefab.ToString() ] != null ).ToString() ); }

                return null;
            }

        } //END InstantiatePrefab()