UnityEngine.Time

---
intcaptureFramerate表示设置每秒的帧率,然后不考虑真实时间
floatdeltaTime表示从上一帧到当前帧时间间隔(秒)
floatfixedDeltaTime进行物理和其他固定帧速率更新的间隔(秒),在Edit->ProjectSettings->Time的Fixed Timestep可以自行设置
floatfixedTime最新的FixedUpdate已启动的时间
floatfixedUnscaledDeltaTime与上一个固定帧到当前帧的时间的时间间隔(秒),该值不受timeScale的影响
floatfixedUnscaledTime最新的FixedUpdate已启动的时间(游戏时间),该值不受timeScale的影响
intframeCount总帧数
boolinFixedTimeStep如果在固定的时间步骤回调(如MonoBehaviour的FixedUpdate)中调用,则返回true,否则返回false
floatmaximumDeltaTime一帧可以占用的最长时间 物理和其他固定帧速率更新(如MonoBehaviour的FixedUpdate)
floatmaximumParticleDeltaTime一个帧可以花费在粒子更新上的最长时间。如果框架花费的时间超过这个时间,则更新程序将分为多个更小的更新
floatrealtimeSinceStartup表示自游戏开始后的总时间,即使暂停也会不断的增加
intrenderedFrameCount渲染帧计数
floatSmoothDeltaTime表示一个平稳的deltaTime,根据前 N帧的时间加权平均的值
floattime表示从游戏开始到现在的时间,会随着游戏的暂停而停止计算
floattimeScale时间缩放,默认值为1。若设置<1,表示时间减慢;若设置>1,表示时间加快;若设置=0,则游戏暂停。可以用来加速、减速和暂停游戏
floattimeSinceLevelLoad表示从当前Scene开始到目前为止的时间,会随着暂停操作而停止
floatunscaledDeltaTime表示从上一帧到当前帧时间间隔(秒),不考虑timescale时候与deltaTime相同
floatunscaledTime从游戏开始到现在的时间,不考虑timescale时候与time相同
//代码控制编译器的暂停和运行
public static void Play()
{
    EditorApplication.isPlaying = true;
}

public static void Pause()
{
    EditorApplication.isPaused = true;
}

public static void Stop()
{
    EditorApplication.isPlaying = false;
}

//对播放模式状态改变的委托
EditorApplication.playmodeStateChanged = OnUnityPlayModeChanged; 
#if USE_UNI_LUA using LuaAPI = UniLua.Lua; using RealStatePtr = UniLua.ILuaState; using LuaCSFunction = UniLua.CSharpFunctionDelegate; #else using LuaAPI = XLua.LuaDLL.Lua; using RealStatePtr = System.IntPtr; using LuaCSFunction = XLua.LuaDLL.lua_CSFunction; #endif using XLua; using System.Collections.Generic; namespace CSObjectWrap { public class UnityEngineMaterialWrap { // 此处可补充UnityEngine.Material的注册和方法实现 } public class UnityEngineAnimationClipWrap { public static void __Register(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Utils.BeginObjectRegister(typeof(UnityEngine.AnimationClip), L, translator, 0, 5, 7, 5); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SampleAnimation", SampleAnimation); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetCurve", SetCurve); Utils.RegisterFunc(L, Utils.METHOD_IDX, "EnsureQuaternionContinuity", EnsureQuaternionContinuity); Utils.RegisterFunc(L, Utils.METHOD_IDX, "ClearCurves", ClearCurves); Utils.RegisterFunc(L, Utils.METHOD_IDX, "AddEvent", AddEvent); Utils.RegisterFunc(L, Utils.GETTER_IDX, "length", get_length); Utils.RegisterFunc(L, Utils.GETTER_IDX, "frameRate", get_frameRate); Utils.RegisterFunc(L, Utils.GETTER_IDX, "wrapMode", get_wrapMode); Utils.RegisterFunc(L, Utils.GETTER_IDX, "localBounds", get_localBounds); Utils.RegisterFunc(L, Utils.GETTER_IDX, "legacy", get_legacy); Utils.RegisterFunc(L, Utils.GETTER_IDX, "humanMotion", get_humanMotion); Utils.RegisterFunc(L, Utils.GETTER_IDX, "events", get_events); Utils.RegisterFunc(L, Utils.SETTER_IDX, "frameRate", set_frameRate); Utils.RegisterFunc(L, Utils.SETTER_IDX, "wrapMode", set_wrapMode); Utils.RegisterFunc(L, Utils.SETTER_IDX, "localBounds", set_localBounds); Utils.RegisterFunc(L, Utils.SETTER_IDX, "legacy", set_legacy); Utils.RegisterFunc(L, Utils.SETTER_IDX, "events", set_events); Utils.EndObjectRegister(typeof(UnityEngine.AnimationClip), L, translator, null, null, null, null, null); Utils.BeginClassRegister(typeof(UnityEngine.AnimationClip), L, __CreateInstance, 1, 0, 0); Utils.RegisterObject(L, translator, Utils.CLS_IDX, "UnderlyingSystemType", typeof(UnityEngine.AnimationClip)); Utils.EndClassRegister(typeof(UnityEngine.AnimationClip), L, translator); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int __CreateInstance(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { if (LuaAPI.lua_gettop(L) == 1) { UnityEngine.AnimationClip __cl_gen_ret = new UnityEngine.AnimationClip(); translator.Push(L, __cl_gen_ret); return 1; } } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.AnimationClip constructor!"); } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SampleAnimation(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); try { { UnityEngine.GameObject go = (UnityEngine.GameObject)translator.GetObject(L, 2, typeof(UnityEngine.GameObject)); float time = (float)LuaAPI.lua_tonumber(L, 3); __cl_gen_to_be_invoked.SampleAnimation(go, time); return 0; } } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SetCurve(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); try { { string relativePath = LuaAPI.lua_tostring(L, 2); System.Type type = (System.Type)translator.GetObject(L, 3, typeof(System.Type)); string propertyName = LuaAPI.lua_tostring(L, 4); UnityEngine.AnimationCurve curve = (UnityEngine.AnimationCurve)translator.GetObject(L, 5, typeof(UnityEngine.AnimationCurve)); __cl_gen_to_be_invoked.SetCurve(relativePath, type, propertyName, curve); return 0; } } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int EnsureQuaternionContinuity(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); try { { __cl_gen_to_be_invoked.EnsureQuaternionContinuity(); return 0; } } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int ClearCurves(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); try { { __cl_gen_to_be_invoked.ClearCurves(); return 0; } } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int AddEvent(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); try { { UnityEngine.AnimationEvent evt = (UnityEngine.AnimationEvent)translator.GetObject(L, 2, typeof(UnityEngine.AnimationEvent)); __cl_gen_to_be_invoked.AddEvent(evt); return 0; } } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_length(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushnumber(L, __cl_gen_to_be_invoked.length); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_frameRate(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushnumber(L, __cl_gen_to_be_invoked.frameRate); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_wrapMode(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.wrapMode); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_localBounds(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); translator.PushUnityEngineBounds(L, __cl_gen_to_be_invoked.localBounds); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_legacy(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushboolean(L, __cl_gen_to_be_invoked.legacy); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_humanMotion(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushboolean(L, __cl_gen_to_be_invoked.humanMotion); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_events(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.events); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 1; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_frameRate(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.frameRate = (float)LuaAPI.lua_tonumber(L, 2); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_wrapMode(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); UnityEngine.WrapMode __cl_gen_value; translator.Get(L, 2, out __cl_gen_value); __cl_gen_to_be_invoked.wrapMode = __cl_gen_value; } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_localBounds(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); UnityEngine.Bounds __cl_gen_value; translator.Get(L, 2, out __cl_gen_value); __cl_gen_to_be_invoked.localBounds = __cl_gen_value; } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_legacy(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.legacy = LuaAPI.lua_toboolean(L, 2); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_events(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.AnimationClip __cl_gen_to_be_invoked = (UnityEngine.AnimationClip)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.events = (UnityEngine.AnimationEvent[])translator.GetObject(L, 2, typeof(UnityEngine.AnimationEvent[])); } catch (System.Exception __gen_e) { return LuaAPI.luaL_error(L, "c# exception:" + __gen_e); } return 0; } } }
最新发布
07-07
Assets\Scripts\Common\VR\VRRecenter.cs(58,9): error CS0103: The name 'Valve' does not exist in the current context using UnityEngine.VR; using UnityEngine; using System.Collections; public class VRRecenter : MonoBehaviour { void OnGUI() { if(GameConfig.singleTon().IsShowRecenter) { if (GUI.Button(new Rect(Screen.width * 0.5f - 60, Screen.height - 20f, 120, 20), "Recenter")) { UnityEngine.XR.InputTracking.Recenter(); } if (GUI.Button(new Rect(Screen.width * 0.5f - 60, Screen.height - 40f, 40, 20), "<<")) { if (Time.timeScale > 1) Time.timeScale -= 1; else if(Time.timeScale > 0.1f) Time.timeScale -= 0.1f; } GUI.Label(new Rect(Screen.width * 0.5f - 20, Screen.height - 40f, 40, 20), Time.timeScale.ToString("f2")); if (GUI.Button(new Rect(Screen.width * 0.5f + 20, Screen.height - 40f, 40, 20), ">>")) { if(Time.timeScale < 1) Time.timeScale += 0.1f; else if(Time.timeScale >= 1) Time.timeScale += 1f; } } } void Update() { if (Input.GetKeyDown(KeyCode.R)) { if (UnityEngine.XR.XRDevice.model.Contains("VIVE") || UnityEngine.XR.XRDevice.model.Contains("vive")) RecenterHTC(); else if (UnityEngine.XR.XRDevice.model.Contains("htc") || UnityEngine.XR.XRDevice.model.Contains("htc")) RecenterHTC(); else UnityEngine.XR.InputTracking.Recenter(); } // 暂时取消,避免影响 if (Input.GetKeyDown(KeyCode.P)) { if (GameConfig.singleTon().IsUseHardware) HardwareManager.Instance.ResetGesture(); } } void RecenterHTC() { Valve.VR.OpenVR.Chaperone.ResetZeroPose(Valve.VR.ETrackingUniverseOrigin.TrackingUniverseStanding); Valve.VR.OpenVR.Compositor.SetTrackingSpace(Valve.VR.ETrackingUniverseOrigin.TrackingUniverseStanding); } }打包时
06-26
使用EmmyLua代码在unity中实现以下功能: 有七张图片,每一张图片都是七步洗手法的一个步骤分别标记为1、2、3、4、5、6、7,有14个图片位置,分为两排,每一排都有7个位子,下面7个位置默认放七个图片,且随机排序,需要将每个图片按照顺序排进上面的7个位置中。图片要求是拖到那个位置。全部到位后显示提交按钮,点击提交按钮,图片不可拖动,首先判断图片的排序位置是否正确,正确就在图片上显示正确的图案,错误就显示错误的图片。 如果全对,提交按钮隐藏,显示“下一步”按钮。 如果位置有错误,提交按钮隐藏,显示“正确答案”按钮,点击后,下面七个位置隐藏,正确和错误的图案隐藏,七个图片自动进行排序移动到正确的位置,正确答案按钮隐藏,显示下一步按钮。 点击下一步按钮,事件完成。 要在unity中手动创建14个位置,手动放置好了7张图片,也创建了三个按钮 要求代码简单易懂,大概就以上要求,可以进行修改优化补充,除此之外,要求填充在以下代码框架中,不能修改框架,可以在框架外添加函数。要求代码通俗易懂,且写出完整代码,不能省略 --- --- Created by sdzz --- DateTime: 2025-05-29 --- ----@class UIXiShouPaiXun:UIBaseView2 local UIXiShouPaiXun = BaseClass("UIXiShouPaiXun", UIBaseView2) -- 创建完调用 function UIXiShouPaiXun:LoadCallBack() -- override --UINameTable init start --上面的七个位置 ---@type UnityEngine.GameObject self.upimg1 = self:FindObj("upimg1") ---@type UnityEngine.GameObject self.upimg2 = self:FindObj("upimg2") ---@type UnityEngine.GameObject self.upimg3 = self:FindObj("upimg3") ---@type UnityEngine.GameObject self.upimg4 = self:FindObj("upimg4") ---@type UnityEngine.GameObject self.upimg5 = self:FindObj("upimg5") ---@type UnityEngine.GameObject self.upimg6 = self:FindObj("upimg6") ---@type UnityEngine.GameObject self.upimg7 = self:FindObj("upimg7") --下面的七个位置 ---@type UnityEngine.GameObject self.downimg1 = self:FindObj("downimg1") ---@type UnityEngine.GameObject self.downimg2 = self:FindObj("downimg2") ---@type UnityEngine.GameObject self.downimg3 = self:FindObj("downimg3") ---@type UnityEngine.GameObject self.downimg4 = self:FindObj("downimg4") ---@type UnityEngine.GameObject self.downimg5 = self:FindObj("downimg5") ---@type UnityEngine.GameObject self.downimg6 = self:FindObj("downimg6") ---@type UnityEngine.GameObject self.downimg7 = self:FindObj("downimg7") --七张图片 ---@type UnityEngine.GameObject self.xiShouImg1 = self:FindObj("xiShouImg1") ---@type UnityEngine.GameObject self.xiShouImg
06-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值