Dec 12, 2013

[Unity3d] GUI Button Image

  1. public Texture2D center;
  2.  
  3. void Start() {
  4. ...
  5. center = (Texture2D) Resources.Load("center", typeof(Texture2D)); // Assigns a texture named "center.png" to a Texture2D(center).
  6.  
  7. ...
  8. }
  9.  
  10. void OnGUI() {
  11. ...
  12. if (GUI.Button (new Rect (850, 570, 32, 32), new GUIContent(center))) {
  13. ...
  14. }
  15. ...
  16. }

[Unity3d] Background Image

41
You're almost there, with the 2nd camera approach. Here's how to do it:
  • Create a new camera (GameObject -> Create Other -> Camera), and name it "Background Camera".
  • Create a new GUI Texture (GameObject -> Create Other -> GUI Texture), and name it "Background Image".
  • Click the "Layer" dropdown menu in the Background Image's inspector pane, and select "Add Layer".
  • In the next free "User Layer" slot, create a new layer name called "Background Image". This will be directly under the layer named "Terrain" if you haven't yet added any others.
  • Select your Background Image in the hierarchy, and give it the desired texture, and set the x, y, width and height under "Pixel Inset" so that it fills the screen appropriately.
  • Near the top of the inspector window, Use the layer dropdown menu to assign your "Background Image" layer that you defined earlier to this gameobject.
  • Now select your Background Camera in the hierarchy, and adjust these settings in the inspector:
    • Un-Check Flare Layer and Audio Listener (but leave GUILayer enabled)
    • Set Clear Flags to Solid Color
    • Set Depth to -1
    • Set Culling Mask, first to "Nothing", and then to "Background Image"
  • Now Select you other (main) camera, and in the inspector:
    • Set its Clear Flags to "Depth Only"
    • Click its culling mask setting, and un-check "Background Image". This should result in the culling mask displaying as "Mixed ..."
Voila, this should give you your GUI Texture rendered by your background camera, behind everything else rendered by your main camera. And for any other additional cameras (eg, other camera angles) that you want to use, just repeat the last two steps on them.

Original Text: 

[android] How to link to google play store app market

1. Search the web and find out URL of your target app.
    It will look like this:
   
    http://play.google.com/store/apps/details?id=com.xxx.xxx


2. Insert the source code.

   Intent intent = new Intent(Intent.ACTION_VIEW,     Uri.parse("http://play.google.com/store/apps/details?id=com.xxx.xxx"));

   startActivity(intent);

Dec 9, 2013

[MySql] External Connection to MySql

mysql -u root -p

input password


mysql>grant all privileges  on *.* to 'root'@'%' identified by 'password';
mysql>flush all privileges;


then restart mysql like  : mysqld restart

if it does not work edit mysql.conf (mysql.ini) and restart.

//bind 127.0.0.1 ---> comment this .

Dec 4, 2013

[android] How to Get Current Time



long now = System.currentTimeMillis();


Date date = new Date(now);


SimpleDateFormat CurDateFormat = new SimpleDateFormat("yyyy년 MM월 dd일");
SimpleDateFormat CurTimeFormat = new SimpleDateFormat("HH시 mm분");
SimpleDateFormat CurYearFormat = new SimpleDateFormat("yyyy");
SimpleDateFormat CurMonthFormat = new SimpleDateFormat("MM");
SimpleDateFormat CurDayFormat = new SimpleDateFormat("dd");
SimpleDateFormat CurHourFormat = new SimpleDateFormat("HH");
SimpleDateFormat CurMinuteFormat = new SimpleDateFormat("mm");

String strCurDate = CurDateFormat.format(date);
String strCurTime = CurTimeFormat.format(date);
String strCurYear = CurYearFormat.format(date);
String strCurMonth = CurMonthFormat.format(date);
String strCurDay = CurDayFormat.format(date);
String strCurHour = CurHourFormat.format(date);
String strCurMinute = CurMinuteFormat.format(date);


byte string convert in C#


    byte[] bStrByte = Encoding.UTF8.GetBytes(str0);   // string -> byte
    string str1 = Encoding.Default.GetString(bStrByte);   // byte -> string