Exemple #1
0
        /// <summary>
        /// Lerp the color of a UI element over time.
        /// </summary>
        /// <param name="targetGraphic">The target UI element to effect.</param>
        /// <param name="color">The new color to lerp to.</param>
        /// <param name="time">The amount of time to lerp over.</param>
        /// <param name="tScale">The method used to evaluate T as the lerp occurs. Defaults to linear.</param>
        /// <param name="callback">Function to call when this lerp has completed.</param>
        /// <returns></returns>
        public static IEnumerator LerpUIColor(
            Graphic targetGraphic, Color color, float time, PercentageEvaluator tScale = null,
            CallOnComplete callback = null)
        {
            if (tScale == null)
            {
                tScale = LINEAR_EVALUATOR;
            }

            float elapsedTime = 0.0f;
            Color startingVal = targetGraphic.color;

            while (elapsedTime < time)
            {
                yield return(null);

                targetGraphic.color = Color.Lerp(startingVal, color, tScale(elapsedTime, time));
                elapsedTime        += Time.deltaTime;
            }

            targetGraphic.color = color;

            if (callback != null)
            {
                callback();
            }
        }
Exemple #2
0
        /// <summary>
        /// Generic coroutine to lerp the position of an object in 3D.
        /// </summary>
        /// <param name="tRef">The transform to move.</param>
        /// <param name="target">The new target position.</param>
        /// <param name="time">Time to lerp over.</param>
        /// <param name="space">Whether to apply this transformation to the local or world position.</param>
        /// <param name="tScale">The method used to evaluate T as the lerp occurs. Defaults to linear.</param>
        /// <param name="callback">Function to call when this lerp has completed.</param>
        public static IEnumerator LerpPosition(
            Transform tRef, Vector3 target, float time, Space space = Space.Self, PercentageEvaluator tScale = null,
            CallOnComplete callback = null)
        {
            if (tScale == null)
            {
                tScale = LINEAR_EVALUATOR;
            }

            if (space == Space.Self)
            {
                yield return(LerpLocalPos(tRef, target, time, tScale));
            }
            else
            {
                yield return(LerpWorldPos(tRef, target, time, tScale));
            }

            if (callback != null)
            {
                callback();
            }
        }
Exemple #3
0
        } //END SendMail


        //---------------------------------//
        public void SendCompleted( object sender, System.ComponentModel.AsyncCompletedEventArgs e, CallOnComplete OnSuccess, CallOnComplete OnFailed )
        //---------------------------------//
        {

            if( e.Error == null )
            {
                if( OnSuccess != null ) { OnSuccess.Invoke(); }
            }
            else if( e.Cancelled )
            {
                if( OnFailed != null ) { OnFailed.Invoke(); }
            }
            else
            {
                //Debug.Log( "MailHelper.cs SendCompleted( FAILED ) Error = " + e.Error );
                if( OnFailed != null ) { OnFailed.Invoke(); }
            }

        } //END SendCompleted
Exemple #4
0
        //-----------------------------------------------------//
        public void SendMail( List<string> sendToAddress, List<string> attachmentsPath, CallOnComplete OnSuccess, CallOnComplete OnFailed )
        //-----------------------------------------------------//
        {

            MailMessage mail = new MailMessage();

            mail.From = new MailAddress( sendFromAddress, displayName );

            foreach( string address in sendToAddress )
            {
                mail.To.Add( address );
            }

            mail.Subject = subject;
            mail.Body = body + System.DateTime.Now.ToString( "MM/dd/yyyy" );

            //Add all of the attachments
            foreach( string path in attachmentsPath )
            {
                try
                {
                    System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment( path );
                    mail.Attachments.Add( attachment );
                }
                catch( Exception ex )
                {
                    Debug.Log( "Exception Error: " + ex );
                }
            }


            SmtpClient smtpServer = new SmtpClient( "smtp.gmail.com", 587 );

            smtpServer.Credentials = new System.Net.NetworkCredential( sendFromAddress, sendFromPassword ) as ICredentialsByHost;

            smtpServer.EnableSsl = true;
            smtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;

            ServicePointManager.ServerCertificateValidationCallback =
                delegate ( object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors )
                { return true; };

            //Send the mail
            //https://forum.unity3d.com/threads/email-scrip-freezing-unity.427627/
            smtpServer.SendCompleted += ( s, e ) =>
            {
                SendCompleted( s, e, OnSuccess, OnFailed );
                mail.Dispose();
            };

            smtpServer.SendAsync( mail, null );

        } //END SendMail
Exemple #5
0
        /// <summary>
        /// Lerps the intensity of a light over the amount of time provided.
        /// </summary>
        /// <param name="light">The light to lerp.</param>
        /// <param name="newIntensity">The new target intensity value.</param>
        /// <param name="time">The amount of time to lerp over.</param>
        /// <param name="tScale">The method used to evaluate T as the lerp occurs. Defaults to linear.</param>
        /// <param name="callback">Function to call when this lerp has completed.</param>
        public static IEnumerator LerpLightIntensity(
            Light light, float newIntensity, float time, PercentageEvaluator tScale = null, CallOnComplete callback = null)
        {
            if (tScale == null)
            {
                tScale = LINEAR_EVALUATOR;
            }

            float elapsedTime = 0.0f, startingVal = light.intensity;

            while (elapsedTime < time)
            {
                light.intensity = Mathf.Lerp(startingVal, newIntensity, tScale(elapsedTime, time));

                elapsedTime += Time.deltaTime;
                yield return(null);
            }

            light.intensity = newIntensity;

            if (callback != null)
            {
                callback();
            }
        }
Exemple #6
0
        /// <summary>
        /// Generic coroutine to scale the rotation of an object in 3D.
        /// </summary>
        /// <param name="tRef">The transform to move.</param>
        /// <param name="target">The new target position.</param>
        /// <param name="time">Time to lerp over.</param>
        /// <param name="tScale">The method used to evaluate T as the lerp occurs. Defaults to linear.</param>
        /// <param name="callback">Function to call when this lerp has completed.</param>
        public static IEnumerator LerpScale(
            Transform tRef, Vector3 target, float time, PercentageEvaluator tScale = null, CallOnComplete callback = null)
        {
            if (tScale == null)
            {
                tScale = LINEAR_EVALUATOR;
            }

            yield return(LerpLocalScale(tRef, target, time, tScale));

            if (callback != null)
            {
                callback();
            }
        }