Home > Net >  [for] how to synthesize the following two code?
[for] how to synthesize the following two code?

Time:04-30

TimeText. Text=the string. Format (" 0-0 at {}, {1:00} ", minutes, seconds).
TimeText. Text=Mathf. CeilToInt (time). The ToString ();


A: hi! Everybody is good! Please help! I have two days still won't do,
Code, this is the time to render device reciprocal Mathf. CeilToInt (time) of the time in realization of inverse function, so I want to have two code output together,
How to make the two together, please?

The source code is as follows:

Using UnityEngine;
Using UnityEngine. UI;

[ExecuteInEditMode]
Public class RadialSlider: MonoBehaviour
{
Public GameObject radial;
Public Image filled;
Public Text timeText;
Public float maxValue=https://bbs.csdn.net/topics/100;
Public float value=https://bbs.csdn.net/topics/0;
Public bool textReversed=false;


Void the Update ()
{
Value/float minutes=Mathf. FloorToInt (60);
Float seconds=Mathf. FloorToInt value % (60);
Float time=(textReversed)? (maxValue - value) : the value;

Value=https://bbs.csdn.net/topics/Mathf.Clamp (value, 0, maxValue);
Float amount=value/maxValue;

Filled. FillAmount=amount;

//timeText. Text=the string. Format (" 0-0 at {}, {1:00} ", minutes, seconds).
//timeText. Text=Mathf. CeilToInt (time). The ToString ();


If (time & lt;=0)

{
Radial. SetActive (false);

}

Else if (time==maxValue)
{
Radial. SetActive (false);
}

The else
{
Radial. SetActive (true);

}


}


}

CodePudding user response:

What meaning be??
TimeText. Text=the string. Format (" 0-0 at {}, {1:00} ", minutes, seconds). + Mathf CeilToInt (time). The ToString ()???????

CodePudding user response:

reference 1st floor Bridge_go response:
what meaning be??
TimeText. Text=the string. Format (" 0-0 at {}, {1:00} ", minutes, seconds). + Mathf CeilToInt (time). The ToString ()???????


Need to present this time format (" 0-0 at {}, {1:00} ", minutes, seconds)
But you need to "bottom"

Is now appear such as:

3:48
3:49
3:50 p.m
3:51

In this way,
I want to be as follows:

3:51
3:50 p.m
3:49
3:48
And so on,,,

CodePudding user response:

TimeText. Text=the string. Format (" 0-0 at {}, {1:00} ", minutes, Mathf. CeilToInt (time) );

CodePudding user response:

You add a timer, every 1 second to perform one, use your input - 1 seconds printed not line?

CodePudding user response:

The
reference 4 floor xuzuning reply:
timeText. Text=the string. Format (" 0-0 at {}, {1:00} ", minutes, Mathf. CeilToInt (time) );


TimeText. Text=the string. Format (" 0-0 at {}, {1:00} ", minutes, seconds, Mathf. CeilToInt (time));

So do as I say the two merged together!

But I just found out that, combined to also won't achieve reciprocal phenomenon, alas

Anyway, thank you!

CodePudding user response:

reference 5 floor dopsop110 reply:
you add a timer, every 1 second to perform one, use your input - 1 seconds printed not line?


Yeah! It should be like this!
I learn c # for a month, can't get, can write to me?

CodePudding user response:

I succeed effect! Thank you for your attention!



using System.Collections;
using System.Collections.Generic;
Using UnityEngine;
Using UnityEngine. UI;

[ExecuteInEditMode]
Public class RadialSlider: MonoBehaviour
{
Public float timeRemaining=10;
Public bool timerIsRunning=false;
Public GameObject radial;
Public Image filled;
Public Text timeText;
Public float maxValue=https://bbs.csdn.net/topics/100;
Public float value=https://bbs.csdn.net/topics/0;
Public bool textReversed=false;

Private void the Start ()
{
//Starts the timer automatically
TimerIsRunning=true;
}

Void the Update ()
{
Float time=(textReversed)? (maxValue - value) : the value;
Value=https://bbs.csdn.net/topics/Mathf.Clamp (value, 0, maxValue);
Float amount=value/maxValue;
Filled. FillAmount=amount;


If (timerIsRunning)
{
If (timeRemaining & gt; 0)
{
TimeRemaining -=Time. DeltaTime;
DisplayTime (timeRemaining);
}
The else
{
The Debug Log (" the Time has run out!" );
TimeRemaining=0;
TimerIsRunning=false;
}
}


If (time & lt;=0)
{
Radial. SetActive (false);
}

Else if (time==maxValue)
{
Radial. SetActive (false);
}

The else
{
Radial. SetActive (true);
}

Void DisplayTime (float timeToDisplay)
{
TimeToDisplay +=1;

Float minutes=Mathf. FloorToInt (timeToDisplay/60);
Float seconds=Mathf. FloorToInt (timeToDisplay % 60);

TimeText. Text=the string. Format (" {0:00}, {1:00} ", minutes, seconds).
}

}


}
  •  Tags:  
  • C#
  • Related