2011년 10월 24일 월요일
Unity3D convert *.js to *.cs
%s/var \(.*\) : \(.*\) = \(.*\);/\2 \1 = \3;/g
%s/var \(.*\) : \(.*\);/\2 \1;/g
%s/function \(.*\)() : \(.*\)/public \2 \1()/g
%s/function \(.*\)/public void \1
%s/boolean/bool
Converted Penelope's Javascript Joysticks to C# (c sharp)
%s/var \(.*\) : \(.*\);/\2 \1;/g
%s/function \(.*\)() : \(.*\)/public \2 \1()/g
%s/function \(.*\)/public void \1
%s/boolean/bool
Converted Penelope's Javascript Joysticks to C# (c sharp)
2011년 8월 9일 화요일
File Access in Unity3D
1. C#
Using FileInfo Class, Read
2. JScript
Using File Class, Read and Write
3. JScript
Using StreamReader Class, Read
Using FileInfo Class, Read
1 using System; 2 using System.IO; 3 4 public class LineReader : MonoBehaviour 5 { 6 protected FileInfo theSourceFile = null; 7 protected StreamReader reader = null; 8 protected string text = " "; // assigned to allow first line to be read below 9 10 void Start () { 11 theSourceFile = new FileInfo ("Test.txt"); 12 reader = theSourceFile.OpenText(); 13 } 14 15 void Update () { 16 if (text != null) { 17 text = reader.ReadLine(); 18 //Console.WriteLine(text); 19 print (text); 20 } 21 } 22 } 23
2. JScript
Using File Class, Read and Write
1 import System.IO; 2 var filePath = "/Users/ResetOfDirectoryPath/testWrite.txt"; 3 4 function Update() { 5 if (Input.GetKeyDown("r")) { 6 WriteFile(filePath); 7 } 8 if (Input.GetKeyDown("f")) { 9 ReadFile(filePath); 10 } 11 } 12 13 function WriteFile(filepathIncludingFileName : String) 14 { 15 var sw : StreamWriter = new StreamWriter(filepathIncludingFileName); 16 sw.WriteLine("Line to write"); 17 sw.WriteLine("Another Line"); 18 sw.Flush(); 19 sw.Close(); 20 } 21 22 function ReadFile(filepathIncludingFileName : String) { 23 sr = new File.OpenText(filepathIncludingFileName); 24 25 input = ""; 26 while (true) { 27 input = sr.ReadLine(); 28 if (input == null) { break; } 29 Debug.Log("line="+input); 30 } 31 sr.Close(); 32 } 33
3. JScript
Using StreamReader Class, Read
1 import System.IO; 2 var fileName = "foo.txt"; 3 function Start () 4 { 5 var sr = new StreamReader(Application.dataPath + "/" + fileName); 6 var fileContents = sr.ReadToEnd(); 7 sr.Close(); 8 var lines = fileContents.Split("\n"[0]); 9 for (line in lines) { 10 print (line); 11 } 12 }
Tag:
C#,
File Access,
JScript,
Unity3D
2011년 4월 11일 월요일
Source code posting test
1 package com.selfinteractive.NdkOpengl; 2 3 import android.app.Activity; 4 import android.os.Bundle; 5 6 public class MainActivity extends Activity { 7 /** Called when the activity is first created. */ 8 @Override 9 public void onCreate(Bundle savedInstanceState) { 10 super.onCreate(savedInstanceState); 11 setContentView(R.layout.main); 12 } 13 }
피드 구독하기:
글 (Atom)