1.Vector3坐标

2.地球,月球,太阳的旋转关系

using System.Collections;
using System.Collections.Generic;
using UnityEngine; public class spere01 : MonoBehaviour {
public GameObject moon;
public GameObject sun;
// Use this for initialization
void Start () { } // Update is called once per frame
void Update () {
// transform.Rotate(Vector3.up, 2, Space.World);//up表示围绕上面轴旋转
moon.transform.Rotate(, , );//月球自传
transform.Rotate(, , );//地球自转
sun.transform.Rotate(Vector3.up);//太阳自转
moon.transform.RotateAround(transform.position, Vector3.up, );//月亮围绕地球转
transform.RotateAround(sun.transform.position, Vector3.up, );//地球围绕太阳转 }
}

3.UI之游戏界面

登录错误提示:

提示登录失败用:

if (this.gameObject.activeSelf)
{
time += Time.deltaTime;//计时器
if (time > 3)
{
failText.gameObject.SetActive(false);//登录失败消失
time = 0;
}
}

进入游戏就有声音:
 slider.maxValue = 100;
slider.minValue = 0;
slider.value = 50;//赋初值
  if (toggle.isOn==true)
{ audio.mute = true;//静音
}
else
{
audio.mute = false;
} audio.volume =(float) (slider.value/100);//把音量条的值赋给背景音乐

//总代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI; public class UIcontrol : MonoBehaviour {
public InputField InputUserName;
public InputField InputPassWord;
public Button button;
public GameObject failText;
public Button closeSetting;
public GameObject Panel;
public Slider slider;
public Toggle toggle;
AudioSource audio; // Use this for initialization
void Start () {
InputUserName = InputUserName.GetComponent<InputField>();
InputPassWord = InputPassWord.GetComponent<InputField>();
button = button.GetComponent<Button>();
closeSetting = closeSetting.GetComponent<Button>();
slider = slider.GetComponent<Slider>();
audio = GetComponent<AudioSource>();
slider.maxValue = ;
slider.minValue = ;
slider.value = ; } public void GetButton()
{
if (InputUserName.text == "huangwei" && InputPassWord.text == "")
{
SceneManager.LoadScene();
}
else
{
failText.gameObject.SetActive(true);//登录失败出现
}
}
public void OpenSetting()
{
Panel.gameObject.SetActive(true);//打开设置
}
public void CloseSetting()//关闭设置
{
Panel.gameObject.SetActive(false);
}
// Update is called once per frame
float time; void Update()
{
if (this.gameObject.activeSelf)
{
time += Time.deltaTime;//计时器
if (time > )
{
failText.gameObject.SetActive(false);//登录失败消失
time = ;
}
} if (toggle.isOn==true)
{ audio.mute = true;//静音
}
else
{
audio.mute = false;
} audio.volume =(float) (slider.value/);//把音量条的值赋给背景音乐
}
}
4.进度条slider: using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; public class test : MonoBehaviour { Text test01;
int num = ;
float time; public Slider slider;
// Use this for initialization
void Start () {
test01 = this.GetComponent<Text>();
slider = slider.GetComponent<Slider>();
slider.maxValue = ;
slider.value = slider.minValue;
} // Update is called once per frame
void Update () {
time += Time.deltaTime;
//if (time >0.1f)
//{
// num++;
// if (num >100)
// {
// num = 100;
// test01.text = num + " %";
// }
// else
// {
// slider.value = num;
// time = 0;
// } //}
//test01.text = num + " %";
//另一种方法 if (time > )
{
time = ;
}
slider.value = time * ;
test01.text = (int)(time*)+ " %";
}
}

5.

技能冷却:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; public class CoolSkill : MonoBehaviour
{
public Image image;
float time;
float f;
public Text text;
bool b = false;
bool bb = true;
// Use this for initialization
void Start()
{
image = image.GetComponent<Image>();
text = text.GetComponent<Text>();
image.fillAmount = ;//默认可以发出技能
}
public void GetBool()
{
if (bb)//限制技能开启后才能使用
{
b = true;
bb = false;
}
}
// Update is called once per frame
void Update()
{
if (b)
{
time += Time.deltaTime;
if (time <= )//技能控制在5秒冷却
{
f = ( - time);//5秒倒计时
image.fillAmount = (f) / ;//image也在360度递减
text.text = (f).ToString();//文本输出倒计时
if (f < 0.1f && f >= )/控制在0.1秒以内结束时才可以重新开启技能
{
bb = true;//重新开启技能Button可以点击了
}
}
else
{
time = ;//超过5秒后时间置零
b = false;/tton点击后又可以计时了
} } }
}
 

最新文章

  1. eCharts动态加载各省份的数据
  2. MySQL FUNCTION 整理
  3. hibernate(1)
  4. jinfo命令的使用
  5. Linux Basis --- commands of vi
  6. T4教程1 T4模版引擎之基础入门
  7. ie8下table的colspan属性与max-with属性的显示错乱问题
  8. C++ Primer 5th 第3章 字符串、向量和数组
  9. 股票K线图-JfreeChart版
  10. 【算法系列学习】巧妙建图,暴搜去重 Counting Cliques
  11. GUI(GroupLayout 分组布局)
  12. 学习Layui 第一天
  13. Python Redis中Scan遇到问题
  14. jmetter 安装 建测试计划详细步骤
  15. [django]主次表如何取出对方数据[主表obj.子表__set()]
  16. shell基础:环境变量
  17. 解决spring boot JavaMailSender部分收件人错误导致发送失败的问题
  18. Python与Go插入排序
  19. Luogu 4725 【模板】多项式对数函数
  20. BAdi:BOM_UPDATE - Check update for BOM Save

热门文章

  1. Vue SSR 配合Java的Javascript引擎j2v8实现服务端渲染2创建Vue2+webpack4项目
  2. zookeeper集群扩容/下线节点实践
  3. RabbitMQ 分布式设置和高可用性讨论
  4. mongodb丢失数据的原因剖析 - 迎风飘来的专栏 - CSDN博客 https://blog.csdn.net/yibing548/article/details/50844310
  5. beginner’s mistake
  6. linux fix the superblock by dumpe2fs fsck
  7. Javascript 面向对象编程(一):封装 作者:yuan一峰
  8. oracle中in和exists的区别
  9. (1.10)SQL优化——mysql 常见SQL优化
  10. .ashx文件与.ashx.cs