Browse Source

Adding instantiated script example

Josh Engebretson 10 years ago
parent
commit
9f873d0899

+ 1 - 1
MultiScript/Resources/Components.asset

@@ -1,6 +1,6 @@
 {
 {
 	"version": 1,
 	"version": 1,
 	"guid": "7f36439132474379a380efcdaa72fce1",
 	"guid": "7f36439132474379a380efcdaa72fce1",
-	"timestamp": 1436737051,
+	"timestamp": 1436820600,
 	"FolderImporter": {}
 	"FolderImporter": {}
 }
 }

+ 16 - 0
MultiScript/Resources/Components/InstantiatedSpinner.js

@@ -0,0 +1,16 @@
+
+// Script instantianted "child" component
+
+var inspectorFields = {
+  speed: 1.0
+}
+
+exports.component = function(self) {
+
+  self.start = function() {
+
+    self.instantated = self.node.createJSComponent("Components/ProtoSpinner.js", { speed: self.speed } );
+
+  }
+
+}

+ 8 - 0
MultiScript/Resources/Components/InstantiatedSpinner.js.asset

@@ -0,0 +1,8 @@
+{
+	"version": 1,
+	"guid": "321f35ca69ac311f4b42aaa41a9e6438",
+	"timestamp": 1436821573,
+	"JavascriptImporter": {
+		"IsComponentFile": false
+	}
+}

+ 21 - 3
MultiScript/Resources/Scenes/TheScene.scene

@@ -5,8 +5,8 @@
 	<attribute name="Smoothing Constant" value="50" />
 	<attribute name="Smoothing Constant" value="50" />
 	<attribute name="Snap Threshold" value="5" />
 	<attribute name="Snap Threshold" value="5" />
 	<attribute name="Elapsed Time" value="0" />
 	<attribute name="Elapsed Time" value="0" />
-	<attribute name="Next Replicated Node ID" value="368" />
-	<attribute name="Next Replicated Component ID" value="1984" />
+	<attribute name="Next Replicated Node ID" value="370" />
+	<attribute name="Next Replicated Component ID" value="1987" />
 	<attribute name="Next Local Node ID" value="16778496" />
 	<attribute name="Next Local Node ID" value="16778496" />
 	<attribute name="Next Local Component ID" value="16777216" />
 	<attribute name="Next Local Component ID" value="16777216" />
 	<attribute name="Variables" />
 	<attribute name="Variables" />
@@ -98,7 +98,7 @@
 	<node id="367">
 	<node id="367">
 		<attribute name="Is Enabled" value="true" />
 		<attribute name="Is Enabled" value="true" />
 		<attribute name="Name" value="Chest" />
 		<attribute name="Name" value="Chest" />
-		<attribute name="Position" value="0 -1.63622 0" />
+		<attribute name="Position" value="0 -1.71745 0" />
 		<attribute name="Rotation" value="1 0 0 0" />
 		<attribute name="Rotation" value="1 0 0 0" />
 		<attribute name="Scale" value="1 1 1" />
 		<attribute name="Scale" value="1 1 1" />
 		<attribute name="Variables" />
 		<attribute name="Variables" />
@@ -113,4 +113,22 @@
 			<attribute name="ComponentFile" value="JSComponentFile;Components/ProtoSpinner.js" />
 			<attribute name="ComponentFile" value="JSComponentFile;Components/ProtoSpinner.js" />
 		</component>
 		</component>
 	</node>
 	</node>
+	<node id="369">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Chest" />
+		<attribute name="Position" value="0 -2.3788 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="1985">
+			<attribute name="Model" value="Model;Cache/8646c0f492bf9bd8b34d8c27e67b7d3c.mdl" />
+			<attribute name="Material" value="Material;Models/Materials/DefaultMaterial.material" />
+		</component>
+		<component type="JSComponent" id="1986">
+			<attribute name="FieldValues">
+				<variant hash="273365031" type="Float" value="8" />
+			</attribute>
+			<attribute name="ComponentFile" value="JSComponentFile;Components/InstantiatedSpinner.js" />
+		</component>
+	</node>
 </scene>
 </scene>

+ 1 - 1
MultiScript/Resources/Scenes/TheScene.scene.asset

@@ -1,6 +1,6 @@
 {
 {
 	"version": 1,
 	"version": 1,
 	"guid": "c5c4f189efd61b5a9fae1d9a15775ea6",
 	"guid": "c5c4f189efd61b5a9fae1d9a15775ea6",
-	"timestamp": 1436737078,
+	"timestamp": 1436820651,
 	"SceneImporter": {}
 	"SceneImporter": {}
 }
 }

+ 1 - 1
MultiScript/Resources/Scripts/main.js

@@ -12,7 +12,7 @@ function start() {
 
 
 	game.createScene3D("Scenes/TheScene.scene");
 	game.createScene3D("Scenes/TheScene.scene");
 
 
-	game.cameraNode.position = [0, 0, -5];
+	game.cameraNode.position = [0, -.5, -8];
 
 
 }
 }
 
 

+ 1 - 1
MultiScript/Resources/Scripts/main.js.asset

@@ -1,7 +1,7 @@
 {
 {
 	"version": 1,
 	"version": 1,
 	"guid": "c8ef552a2cb24304739e8c048fdaa986",
 	"guid": "c8ef552a2cb24304739e8c048fdaa986",
-	"timestamp": 1436737345,
+	"timestamp": 1436820690,
 	"JavascriptImporter": {
 	"JavascriptImporter": {
 		"IsComponentFile": false
 		"IsComponentFile": false
 	}
 	}