This is simple script to make inventory window(n x 1 matrix). You can change bool variable 'ShowStickList' when user click certain keyboard button then OnGUI method will(or won't) draw a window. Method 'InventoryWindow' makes buttons that each is an item in BindableList in Inventory window. When user click one of those buttons, 'StickReadyToBind()' method will be called


Script above is to make flexible inventory that contains all items in ArrayList. And if you wanna create Inventory fixed size so there are buttons the same number of items and blank squares, this is the script.



This is script that makes m x n matrix inventory. It will create buttons while there are items in the list, then rest will be just simple square(see 'if{} else{}' in the script)

'GUI.DragWindow()' method is to make that inventory dragable. User can move window by click and drag by mouse





'중국인턴(Intern In China) > 업무(Tasks)' 카테고리의 다른 글

Change Color of Z Sticks(Theater Mode)  (0) 2017.01.11
Unity Http Put Json Type  (0) 2017.01.11
Unity HTTP (www) get, put, post  (0) 2017.01.10
Parsing data from Json  (0) 2017.01.10
Loaded Json Data from Server@@@  (0) 2017.01.06


selectedSticks contains sticks to change one color

AllChangedSticks is sum of selectedSticks selected between clicking Send Color button

This method is to add or remove a stick to selected list


When user click color button that he/she wants to change, All sticks change color member to new one



Then, they will be added in to AllChangeLists. When there is already added, the latest stick will replace old one



When user click send button, Json data will be written.


Then Send Json data through Http put method to server


'중국인턴(Intern In China) > 업무(Tasks)' 카테고리의 다른 글

Unity Making Inventory Script  (0) 2017.01.16
Unity Http Put Json Type  (0) 2017.01.11
Unity HTTP (www) get, put, post  (0) 2017.01.10
Parsing data from Json  (0) 2017.01.10
Loaded Json Data from Server@@@  (0) 2017.01.06

This is the code to connect server by HTTP Put method and send Json data in Unity3D


use HttpWebRequest Class to request, and Stream class to put Json data. Then, Response will be obtained using HttpWebResponse and  StreamReader class.

Response is in StreamReader.ReadToEnd();


'중국인턴(Intern In China) > 업무(Tasks)' 카테고리의 다른 글

Unity Making Inventory Script  (0) 2017.01.16
Change Color of Z Sticks(Theater Mode)  (0) 2017.01.11
Unity HTTP (www) get, put, post  (0) 2017.01.10
Parsing data from Json  (0) 2017.01.10
Loaded Json Data from Server@@@  (0) 2017.01.06

http://blog.naver.com/PostView.nhn?blogId=sonmg&logNo=220510568356


public enum EType {

GET,

POST,

PUT,

DELETE

};


[SerializeField] public EType _type = EType.GET;



private void OnButtonClicked()

{

Debug.Log ("OnButtonClicked... " + _type);


if (_type == EType.GET)

{

  // GET

  string url = "http://127.0.0.1:3000/method_get_test/users";

  WWW www = new WWW (url);

  StartCoroutine(WaitForRequest(www));

}

else if (_type == EType.POST)

{

  // POST

  string url = "http://127.0.0.1:3000/method_post_test/user";

  WWWForm form = new WWWForm();

  form.AddField("id", "8");

  form.AddField("name", "brian8");

  WWW www = new WWW (url, form);

  StartCoroutine(WaitForRequest(www));

}

else if (_type == EType.PUT)

{

  // PUT

  string url = "http://127.0.0.1:3000/method_put_test/user/id/8/ddddd";

  HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);

  httpWebRequest.ContentType = "text/json";

  httpWebRequest.Method = "PUT";


  HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

  using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))

  {

   string responseText = streamReader.ReadToEnd();

   //Now you have your response.

   //or false depending on information in the response

   Debug.Log(responseText);

  }   

}

else if (_type == EType.DELETE)

{

  // DELETE

  string url = "http://127.0.0.1:3000/method_del_test/user/id/8";

  HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);

  httpWebRequest.ContentType = "text/json";

  httpWebRequest.Method = "DELETE";


  HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

  using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))

  {

   string responseText = streamReader.ReadToEnd();

   //Now you have your response.

   //or false depending on information in the response

   Debug.Log(responseText);

  }   

}

}


IEnumerator WaitForRequest(WWW www)

{

yield return www;


if (www.error == null)

{

  // request completed!

  Debug.Log (www.text);

}

else

{

  // something wrong!

  Debug.Log ("WWW error: " + www.error);

}

}


'중국인턴(Intern In China) > 업무(Tasks)' 카테고리의 다른 글

Change Color of Z Sticks(Theater Mode)  (0) 2017.01.11
Unity Http Put Json Type  (0) 2017.01.11
Parsing data from Json  (0) 2017.01.10
Loaded Json Data from Server@@@  (0) 2017.01.06
Unity read Json data  (0) 2017.01.06


I used www(which is a class that connect HTTP) to get Json data from server. The Data will be stored in www.text value type string, and I splited the data every }, as it contains several information of several sticks and I need to split them.


And printTextSplit(string[] str) method does that task


Code is below:



StickList is the list of connected Z Sticks and every stick information will be printed in console by Debug.Log command. StickList.Count is a int value that the number of sticks connected

'중국인턴(Intern In China) > 업무(Tasks)' 카테고리의 다른 글

Unity Http Put Json Type  (0) 2017.01.11
Unity HTTP (www) get, put, post  (0) 2017.01.10
Loaded Json Data from Server@@@  (0) 2017.01.06
Unity read Json data  (0) 2017.01.06
First Assignment in China  (0) 2017.01.05

YEEEEEESSSSSSSS!! I just succeeded to load informations from Server as Json Data file!!


It collect information from server every second..!!!





Now I will parsing datas to manage at my Unity project. then I need to research how to send JsonData back to Server


AND Special Thanks to 

http://www.itpaper.co.kr/14127/?ckattempt=1

'중국인턴(Intern In China) > 업무(Tasks)' 카테고리의 다른 글

Unity HTTP (www) get, put, post  (0) 2017.01.10
Parsing data from Json  (0) 2017.01.10
Unity read Json data  (0) 2017.01.06
First Assignment in China  (0) 2017.01.05
Read Json file in Unity3D  (0) 2017.01.05

Reading Json data using dlll had dictionary error, and I studied using JsonUtility


Through script, class should be identified Serializable like below:


[Serializable]            //using System must be added

class Data

{

    public string name;

    public List<string> likes;

    public int level;

}


and create a variable type of 'Data', then use JsonUtility.ToJson method to convert 'Data' type to Json like below


        var data = new Data();


        data.name = "Park";

        data.level = 10;

        data.likes = new List<string>() {

            "dog", "cat"

        };


        /*

{

    "name": "Park",

    "likes": [

        "dog",

        "cat"

    ],

    "level": 10

}

*/

        Debug.Log(JsonUtility.ToJson(data, prettyPrint: true));


Annotation in /* */ would be printed in console like below 




Thanks to: http://pjc0247.tistory.com/32

'중국인턴(Intern In China) > 업무(Tasks)' 카테고리의 다른 글

Unity HTTP (www) get, put, post  (0) 2017.01.10
Parsing data from Json  (0) 2017.01.10
Loaded Json Data from Server@@@  (0) 2017.01.06
First Assignment in China  (0) 2017.01.05
Read Json file in Unity3D  (0) 2017.01.05

 ZStick is a stick that has a LED with buttons. A set of ZSticks can be used in any places where there are audiences. Through it, they can vote or do some performances as its' LED has 6 lights(RGB, CMY and White)


There is an Android App that can set 2 modes(vote or Scene). Vote mode is when users of ZSticks press one of 3 buttons, result is displayed. The other mode, Scene, is used for performance so App can control all ZStick's colors. So it can make all sticks to light same color, or select sticks and change theirs.


 So Our first task is that make a program using C/C++(Console or Window Program) or C#(Unity) to control a set of ZSticks. So we should make a program that connect with Z Sticks through network and can control or collect data from them. I think it will be really funny..!

'중국인턴(Intern In China) > 업무(Tasks)' 카테고리의 다른 글

Unity HTTP (www) get, put, post  (0) 2017.01.10
Parsing data from Json  (0) 2017.01.10
Loaded Json Data from Server@@@  (0) 2017.01.06
Unity read Json data  (0) 2017.01.06
Read Json file in Unity3D  (0) 2017.01.05


Learn how to parse JSON data in Unity using C# and the LitJson library.

What is JSON?
http://json.org/

LitJson
http://lbv.github.io/litjson/

Unity DLL Manual
http://docs.unity3d.com/Manual/UsingD...

Unity Visual Studio Tools
https://www.visualstudio.com/en-us/fe...

Have a question or comment? Leave one below or hit me up on twitter at:
https://twitter.com/AwfulMedia

Alright, so this is my first video in over a year. I know it was sucky of me to just abandon the channel without explanation. I've been busier than usual and just lost interest. With that said, I want to apologize for how it went down and I hope we can put it behind us and learn how to make some awesome stuff.

출처: http://unitytutorial.tistory.com/20 [유니티 러닝 센터]


======================================================================


I've got a mission to create program (or Interface) and it need to read/write Json data file

'중국인턴(Intern In China) > 업무(Tasks)' 카테고리의 다른 글

Unity HTTP (www) get, put, post  (0) 2017.01.10
Parsing data from Json  (0) 2017.01.10
Loaded Json Data from Server@@@  (0) 2017.01.06
Unity read Json data  (0) 2017.01.06
First Assignment in China  (0) 2017.01.05

+ Recent posts