wiki.sine.space | sinespace

Difference between revisions of "Scripting/SResource"

From wiki.sine.space
Jump to: navigation, search
Line 1: Line 1:
 
=Public Attributes=
 
=Public Attributes=
{{ScriptFunction|string|Name|{ get;}|Returns the name of the resource as entered in the scripting runtime|5= <pre>ResourceName = Space.Resources[1].Name</pre>|6=<pre></pre>}}
+
{{ScriptFunction|string|Name|{ get;}|Returns the name of the resource as entered in the scripting runtime|5= <pre>ResourceName = Space.Resources[1].Name</pre>|6=<pre>--the below script will search through the Scripting Runtime's resources
 +
--and return the first instance of an Animation Clip
 +
--[You need to add a few resources to the scripting runtime and make one of them an animation]
 +
 
 +
 
 +
resources = Space.Resources
 +
 
 +
for i = 1, #resources do
 +
if resources[i].Type == "AnimationClip" then
 +
  Space.Log("Resource #".. i .. " is an Animation Clip. The resource name is: " .. resources[i].Name)
 +
  break
 +
end
 +
  end</pre>}}
  
  
Line 6: Line 18:
  
  
{{ScriptFunction|string|Type|{ get;}|Returns the type of the resource as a string|5= <pre>ResourceType = Space.GetResource("Resource Name").Type</pre>|6=<pre></pre>}}
+
{{ScriptFunction|string|Type|{ get;}|Returns the type of the resource as a string|5= <pre>ResourceType = Space.GetResource("Resource Name").Type</pre>|6=<pre>--the below script will search through the Scripting Runtime's resources
 +
--and return the first instance of an Animation Clip
 +
--[You need to add a few resources to the scripting runtime and make one of them an animation]
 +
 
 +
 
 +
resources = Space.Resources
 +
 
 +
for i = 1, #resources do
 +
if resources[i].Type == "AnimationClip" then
 +
  Space.Log("Resource #".. i .. " is an Animation Clip. The resource name is: " .. resources[i].Name)
 +
  break
 +
end
 +
  end</pre>}}
  
  

Revision as of 10:46, 23 September 2021

Public Attributes

Name

string Name { get;}

Returns the name of the resource as entered in the scripting runtime

ResourceName = Space.Resources[1].Name


--the below script will search through the Scripting Runtime's resources
--and return the first instance of an Animation Clip
--[You need to add a few resources to the scripting runtime and make one of them an animation]


resources = Space.Resources

for i = 1, #resources do
 if resources[i].Type == "AnimationClip" then
  Space.Log("Resource #".. i .. " is an Animation Clip. The resource name is: " .. resources[i].Name)
  break
 end
  end


Properties

Type

string Type { get;}

Returns the type of the resource as a string

ResourceType = Space.GetResource("Resource Name").Type


--the below script will search through the Scripting Runtime's resources
--and return the first instance of an Animation Clip
--[You need to add a few resources to the scripting runtime and make one of them an animation]


resources = Space.Resources

for i = 1, #resources do
 if resources[i].Type == "AnimationClip" then
  Space.Log("Resource #".. i .. " is an Animation Clip. The resource name is: " .. resources[i].Name)
  break
 end
  end


AsText

string AsText { get; }

Converts the resource's type from SResource type to string

Text = Space.GetResource("Resource Name").AsText



AsGameObject

SGameObject AsGameObject { get;}


GameObject = Space.GetResource("Resource Name").AsGameObject



AsMaterial

SMaterial AsMaterial { get; }

Converts the resource's type from SResource to SMaterial

Material = Space.GetResource("Resource Name").AsMaterial



TextureWidth

float TextureWidth { get; }

Returns the Texture Width of this resource

TextureWidth = Space.GetResource("Resource Name").TextureWidth



TextureHeight

float TextureHeight { get; }

Returns the Texture Height of this resource

TextureHeight = Space.GetResource("Resource Name").TextureHeight