-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renderer, MeshRenderer and SkinnedMeshRenderer defs
- Loading branch information
Showing
7 changed files
with
1,389 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UnityEngine; | ||
|
||
namespace CVRLua.Lua.LuaDefs | ||
{ | ||
static class MeshRendererDefs | ||
{ | ||
const string c_destroyed = "MeshRenderer is destroyed"; | ||
|
||
static readonly List<(string, LuaInterop.lua_CFunction)> ms_metaMethods = new List<(string, LuaInterop.lua_CFunction)>(); | ||
static readonly List<(string, (LuaInterop.lua_CFunction, LuaInterop.lua_CFunction))> ms_staticProperties = new List<(string, (LuaInterop.lua_CFunction, LuaInterop.lua_CFunction))>(); | ||
static readonly List<(string, LuaInterop.lua_CFunction)> ms_staticMethods = new List<(string, LuaInterop.lua_CFunction)>(); | ||
static readonly List<(string, (LuaInterop.lua_CFunction, LuaInterop.lua_CFunction))> ms_instanceProperties = new List<(string, (LuaInterop.lua_CFunction, LuaInterop.lua_CFunction))>(); | ||
static readonly List<(string, LuaInterop.lua_CFunction)> ms_instanceMethods = new List<(string, LuaInterop.lua_CFunction)>(); | ||
|
||
internal static void Init() | ||
{ | ||
ms_staticMethods.Add((nameof(IsMeshRenderer), IsMeshRenderer)); | ||
|
||
//ms_instanceProperties.Add(("additionalVertexStreams", (?,?))); | ||
ms_instanceProperties.Add(("subMeshStartIndex", (GetSubMeshStartIndex, null))); | ||
|
||
RendererDefs.InheritTo(ms_metaMethods, ms_staticProperties, ms_staticMethods, ms_instanceProperties, ms_instanceMethods); | ||
} | ||
|
||
internal static void RegisterInVM(LuaVM p_vm) | ||
{ | ||
p_vm.RegisterClass(typeof(MeshRenderer), null, ms_staticProperties, ms_staticMethods, ms_metaMethods, ms_instanceProperties, ms_instanceMethods); | ||
} | ||
|
||
// Static methods | ||
static int IsMeshRenderer(IntPtr p_state) | ||
{ | ||
var l_argReader = new LuaArgReader(p_state); | ||
MeshRenderer l_render = null; | ||
l_argReader.ReadNextObject(ref l_render); | ||
l_argReader.PushBoolean(l_render != null); | ||
return l_argReader.GetReturnValue(); | ||
} | ||
|
||
// Instance properties | ||
static int GetSubMeshStartIndex(IntPtr p_state) | ||
{ | ||
var l_argReader = new LuaArgReader(p_state); | ||
MeshRenderer l_render = null; | ||
l_argReader.ReadObject(ref l_render); | ||
if(!l_argReader.HasErrors()) | ||
{ | ||
if(l_render != null) | ||
l_argReader.PushInteger(l_render.subMeshStartIndex); | ||
else | ||
{ | ||
l_argReader.SetError(c_destroyed); | ||
l_argReader.PushBoolean(false); | ||
} | ||
} | ||
else | ||
l_argReader.PushBoolean(false); | ||
|
||
l_argReader.LogError(); | ||
return 1; | ||
} | ||
} | ||
} |
Oops, something went wrong.