Ejemplo n.º 1
0
        } //END Instance

        //--------------------------------------//
        public void Awake()
        //--------------------------------------//
        {
            DestroyDuplicateInstance();

            if( transform.parent == null )
            {
                DontDestroyOnLoad( transform.gameObject );
            }

            if( showDebug ) { Debug.Log( "ScreenFadeManager.cs Awake() start" ); }

            if( GetComponentInChildren<UIColorTweenManager>() != null )
            {
                uiColorTweenManager_ScreenFader = GetComponentInChildren<UIColorTweenManager>();
            }

            if( uiColorTweenManager_ScreenFader != null )
            {
                uiColorTweenManager_ScreenFader.ForceAlpha( 0f );
            }

            if( showDebug ) { Debug.Log( "ScreenFadeManager.cs Awake() end" ); }

        } //END Awake
Ejemplo n.º 2
0
        } //END CheckIfWeShouldChangeModelOnStart

        //--------------------------------//
        /// <summary>
        /// Replaces the existing instantiated 3D model with the one passed in. Expects a prefab/gameObject reference to clone
        /// </summary>
        /// <param name="newModelToClone">The GameObject prefab we want to clone</param>
        public void ChangeModel( GameObject newModelToClone )
        //--------------------------------//
        {
#if LEANTOUCH
            leanForceRigidbody = null;
            leanFingerSwipe = null;
#endif

            //Destroy any existing model(s)
            if( faceCameraTransform.childCount > 0 )
            {
#if UNITY_EDITOR
                //Wait a moment before calling DestroyImmediate to make sure no logic is running
                UnityEditor.EditorApplication.delayCall += () =>
                {
                    DestroyImmediate( faceCameraTransform.GetChild(0).gameObject );
                };
#else
                Destroy( faceCameraTransform.GetChild(0).gameObject );
#endif
            }

            //Instantiate the new model to show
            if( newModelToClone != null )
            {
                model = Instantiate( newModelToClone, faceCameraTransform );
                
                //Remove (Clone) from the models name
                if( model.name.Contains( "(Clone)" ))
                {
                    string[] words = model.name.Split( '(' );
                    model.name = words[ 0 ];
                }
                
                model.SetActive( true );

                transformToMove = this.transform;
                transformToPinch = this.transform;
                transformToTwist = this.transform;
                /*
                transformToMove = model.transform;
                transformToPinch = model.transform;
                transformToTwist = model.transform;
                */

            }

            //Add a ColorTweenManager to the new model, and link all of the renderers to it
            if ( model.GetComponent<UIColorTweenManager>() == null )
            {
                uiColorTweenManager = model.AddComponent<UIColorTweenManager>();
            }
            else
            {
                uiColorTweenManager = model.GetComponent<UIColorTweenManager>();
            }

            //Find all of the Renderers on the object, attach a UIColorTweener to those gameObjects and link them to the uiColorTweenManager
            if( model.GetComponentInChildren<Renderer>() != null )
            {
                uiColorTweenManager.tweeners = new List<UIColorTweener>();

                foreach( Renderer rend in model.GetComponentsInChildren<Renderer>().ToList() )
                {
                    if ( rend != null && rend.gameObject.GetComponent<UIColorTweener>() == null )
                    {
                        uiColorTweenManager.tweeners.Add( rend.gameObject.AddComponent<UIColorTweener>() );
                    }
                    else if( rend != null && rend.gameObject.GetComponent<UIColorTweener>() != null )
                    {
                        uiColorTweenManager.tweeners.Add( rend.gameObject.GetComponent<UIColorTweener>() );
                    }
                }
            }

            CheckIfWeShouldAddMeshColliderToModel();

            CheckIfWeShouldAddRigidbodyToModel();

        } //END ChangeModel
Ejemplo n.º 3
0
        //--------------------------------------//
        public void Awake()
        //--------------------------------------//
        {

            //Find the list to add these color tweeners to, or make a new one
            if( uiColorTweenManager_AddToList == null && this.GetComponent<UIColorTweenManager>() != null )
            {
                uiColorTweenManager_AddToList = this.GetComponent<UIColorTweenManager>();
            }
            else if( uiColorTweenManager_AddToList == null && this.GetComponent<UIColorTweenManager>() == null )
            {
                uiColorTweenManager_AddToList = this.gameObject.AddComponent<UIColorTweenManager>();
            }



            //Add color tweeners to any image components we find
            List<Image> images = this.GetComponentsInChildren<Image>().ToList();

            if( images != null && images.Count > 0 )
            {
                foreach( Image image in images )
                {
                    if( image.GetComponent<UIColorTweener>() == null )
                    {
                        UIColorTweener colorTweener = image.gameObject.AddComponent<UIColorTweener>();
                        colorTweeners.Add( colorTweener );
                        colorTweener.color_Show = image.color;
                        colorTweener.color_Hide = new Color( image.color.r, image.color.g, image.color.b, 0f );
                        colorTweener.color_Default = image.color;
                    }
                }
            }
            



            //Add any color tweeners we created to the manager
            if( uiColorTweenManager_AddToList != null && colorTweeners != null && colorTweeners.Count > 0 )
            {
                //If our manager already has tweeners, check each tweener we want to add and make sure it hasn't already been added
                if( uiColorTweenManager_AddToList.tweeners != null && uiColorTweenManager_AddToList.tweeners.Count > 0 )
                {
                    foreach( UIColorTweener tweener in colorTweeners )
                    {
                        if( !uiColorTweenManager_AddToList.tweeners.Contains( tweener ) )
                        {
                            uiColorTweenManager_AddToList.tweeners.Add( tweener );
                        }
                    }
                }

                //If the manager has tweeners but the list is empty
                else if( uiColorTweenManager_AddToList.tweeners != null && uiColorTweenManager_AddToList.tweeners.Count == 0 )
                {
                    uiColorTweenManager_AddToList.tweeners = colorTweeners;
                }

                //If the manager has no tweeners (not instantiated)
                else if( uiColorTweenManager_AddToList.tweeners == null )
                {
                    uiColorTweenManager_AddToList.tweeners = colorTweeners;
                }
            }


        } //END Awake