
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
黃彥霖 發表在 痞客邦 留言(0) 人氣(523)
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
黃彥霖 發表在 痞客邦 留言(0) 人氣(862)
預設 Unity C# 使用 Unsafe 會報錯,所以我們必須在 Unity 專案的 Assets 資料夾中建立 .rsp 文件,以更改編譯設定
每個腳本語言使用的 rsp 文件都不同,請依造您的需求參考以下表格來修改,例如 C# 就是 gmcs.rsp ....等等
語言 |
檔案名稱 & 路徑 |
C# |
<Project Path>/Assets/smcs.rsp |
C# - Editor Scripts |
<Project Path>/Assets/gmcs.rsp |
UnityScript |
<Project Path>/Assets/us.rsp |
Boo |
<Project Path>/Assets/boo.rsp |
黃彥霖 發表在 痞客邦 留言(0) 人氣(1,078)
using UnityEngine;
using System.Collections;
using System.Text.RegularExpressions;
public class Test : MonoBehaviour {
void Awake () {
string[] array = Regex.Split("AAA123BBB123CCC123", "123", RegexOptions.IgnoreCase);
foreach(string s in array){
print (s);
}
}
}
-----------------------------------------------------------------------
輸出結果:
AAA
BBB
CCC
黃彥霖 發表在 痞客邦 留言(0) 人氣(1,401)
var s = s.replace(/\被替換的字串/g,"新字串");
例如:
var s = "AAA,BBB,CCC";
s = s.replace(/\,/g,"<br>");
輸出:
AAA<br>BBB<br>CCC
黃彥霖 發表在 痞客邦 留言(0) 人氣(131)
function getParameter(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
黃彥霖 發表在 痞客邦 留言(0) 人氣(566)
<script>
var jsontext = '{"name":"Loli","age":"12","phone":["091314520","021314520"]}';
黃彥霖 發表在 痞客邦 留言(0) 人氣(2,171)
using UnityEngine;
using System.Collections;
using System;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
public class NewBehaviourScript : MonoBehaviour {
string url = "http://219.85.250.149:8080/UploadFile"; // 伺服器上傳網址
string filePath = "/Users/Loli/Desktop/Easy Download/23-121026161100.jpg"; // 檔案路徑
void Start () {
UploadFilesToRemoteUrl (url, filePath);
}
private string UploadFilesToRemoteUrl(string url, string file)
{
// Create a boundry
string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x");
// Create the web request
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ContentType = "multipart/form-data; boundary=" + boundary;
httpWebRequest.Method = "POST";
httpWebRequest.KeepAlive = true;
httpWebRequest.AllowWriteStreamBuffering = false;
httpWebRequest.Credentials =
System.Net.CredentialCache.DefaultCredentials;
// Get the boundry in bytes
byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
// Get the header for the file upload
string headerTemplate = "Content-Disposition: form-data; name=\"{0}\";filename=\"{1}\"\r\n Content-Type: application/octet-stream\r\n\r\n";
// Add the filename to the header
string header = string.Format(headerTemplate, "file", file);
//convert the header to a byte array
byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
// Add all of the content up.
httpWebRequest.ContentLength = new FileInfo(file).Length + headerbytes.Length + (boundarybytes.Length * 2) + 2;
// Get the output stream
Stream requestStream = httpWebRequest.GetRequestStream();
// Write out the starting boundry
requestStream.Write(boundarybytes, 0, boundarybytes.Length);
// Write the header including the filename.
requestStream.Write(headerbytes, 0, headerbytes.Length);
// Open up a filestream.
FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read);
// Use 4096 for the buffer
byte[] buffer = new byte[4096];
int bytesRead = 0;
// Loop through whole file uploading parts in a stream.
while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
{
requestStream.Write(buffer, 0, bytesRead);
requestStream.Flush();
}
boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
// Write out the trailing boundry
requestStream.Write(boundarybytes, 0, boundarybytes.Length);
// Close the request and file stream
requestStream.Close();
fileStream.Close();
WebResponse webResponse = httpWebRequest.GetResponse();
Stream responseStream = webResponse.GetResponseStream();
StreamReader responseReader = new StreamReader(responseStream);
string responseString = responseReader.ReadToEnd();
// Close response object.
webResponse.Close();
return responseString;
}
}
黃彥霖 發表在 痞客邦 留言(1) 人氣(2,782)

這是一個用下拉式選單選擇場景,當遊戲運行後,玩家點擊物體(按鈕)就會依造選擇的場景地進入指定場景
還有如果按下 Esc 鍵,或手機的 Back 鍵也會觸發進入到指定的場景中,
這可以使用 UseBack 來控制是否要啟用這個功能
可以設定啟用 Click (滑鼠點擊),或 Back (按 Esc 鍵、按手機的 Back 鍵)
下拉選單:選擇要進入的場景
黃彥霖 發表在 痞客邦 留言(0) 人氣(3,000)