2015年8月17日 星期一

unity c# get set class

private string name;
public string Name
{
    get
    {
        return this.name;
    }
    set
    {
        this.name = value;
    }
}


Name="asd";
Name2 =Name;

2015年8月9日 星期日

ngui uitexture change



        UITexture renderer = GetComponent<UITexture>();
        renderer.mainTexturewww.texture;

2015年6月11日 星期四

check if a file exists on the hard drive ; File.Exists( );

  1. if (System.IO.File.Exists("myfile.txt"))
  2. {
  3. //do stuff
  4. }

siaqodb , if it is empty , null

  
      Siaqodb siaqodb = DBManager.Instance.GetInstance ();

        if(siaqodb!=null){
            showSiaqoDB();
        }
        else{
            Debug.Log("siqqo is empty");
        }

activeInHierarchy , 看有沒有被打開

        

else if (appPageGobj.activeInHierarchy)
        {
            aboutBackIndex = 2;
            appPageGobj.SetActive (false);
            menuPageGobj.SetActive(false);
        }



2015年6月1日 星期一

Object.Instantiate


initiate position:
 // Instantiates 10 copies of prefab each 2 units apart from each other

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Transform prefab;
    void Start() {
        for (int i = 0; i < 10; i++) {
            Instantiate(prefab, new Vector3(i * 2.0F, 0, 0), Quaternion.identity);
            i++;
        }
    }
}
Instantiate is most commonly used to instantiate projectiles, AI Enemies, particle explosions or wrecked object replacements.


using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Rigidbody projectile;
    void Update() {
        if (Input.GetButtonDown("Fire1")) {
            Rigidbody clone;
            clone = Instantiate(projectile, transform.position, transform.rotation) as Rigidbody;
            clone.velocity = transform.TransformDirection(Vector3.forward * 10);
        }
    }
}
            GameObject item;
            I18nData holder = (I18nData)Resources.Load("I18nDataHolder"typeof(I18nData));
            if (holder.lang == "CN") {
                item = Instantiate(Resources.Load("Prefab/LitemButton1CN"))as GameObject;
            }
            else if (holder.lang == "EN") {
                item = Instantiate(Resources.Load("Prefab/LitemButton1EN"))as GameObject;
            }
            else if (holder.lang == "JP") {
                item = Instantiate(Resources.Load("Prefab/LitemButton1JP"))as GameObject;
            }
            else{
                item = Instantiate(Resources.Load("Prefab/ItemBubble"))as GameObject;
            }








2015年5月12日 星期二

best resolution gearVR unity 3d 5


Parse Adding user unity


var user = new Parse.User(); user.set("username", "my name"); user.set("password", "my pass"); user.set("email", "email@example.com"); // other fields can be set just like with Parse.Object user.set("phone", "415-392-0202"); user.signUp(null, { success: function(user) { // Hooray! Let them use the app now. }, error: function(user, error) { // Show the error message somewhere and let the user try again. alert("Error: " + error.code + " " + error.message); } });




from
https://www.blogger.com/blogger.g?blogID=1171197136625264706#allposts/src=dashboard

2015年5月4日 星期一

account

https://share.oculus.com

jy02927731@yahoo.com.hk
00423564

signature ID
41009c2bf2e29175
https://developer.oculus.com/osig/





2015年2月9日 星期一

difference between Update and FixedUpdate

 Update
update in the amount of Framerate

 FixedUpdate
update in the amount of 24fps

unity - showing instance object [System.Serializable]


[System.Serializable]

public class Boundary{
    public float minX,maxX,minZ,maxZ;
    }



public class PlayerControlor : MonoBehaviour {
    public Boundary boundary;



}

unity - rigidbody rotate






        rigidbody.velocity = movement*speed;


        rigidbody.rotation = Quaternion.Euler (0,0,-rigidbody.velocity.x *tilt);

unity - get keyboard arrow ,



        float moveX = Input.GetAxis ("Horizontal");
        float moveY = Input.GetAxis ("Vertical");



        Vector3 movement = new Vector3 (moveX0.0fmoveY);


        rigidbody.velocity = movement*speed;









unity - flight, plane control

[System.Serializable]

public class Boundary{
    public float minX,maxX,minZ,maxZ;
    }

public class PlayerControlor : MonoBehaviour {
    public Boundary boundary;
    public float speed=0.01f;
    public float tilt=4;

    void FixedUpdate(){
        float moveX = Input.GetAxis ("Horizontal");
        float moveY = Input.GetAxis ("Vertical");

        Vector3 movement = new Vector3 (moveX0.0fmoveY);
        rigidbody.velocity = movement*speed;
        rigidbody.rotation = Quaternion.Euler (0,0,-rigidbody.velocity.x *tilt);

        rigidbody.position = new Vector3 (
            Mathf.Clamp(rigidbody.position.x,boundary.minX,boundary.maxX),
            0.0f,
            Mathf.Clamp(rigidbody.position.z,boundary.minZ,boundary.maxZ)
                );
    }
}

2015年2月8日 星期日

unity 3d, texture material

3d model:
http://tf3dm.com/3d-models/unity

petergo
jy02927731@yahoo.com.hk
00423564


https://3dwarehouse.sketchup.com/?redirect=1
facebook




2015年2月6日 星期五

Unity - panel trigger

public class gameOverTrigger : MonoBehaviour {

    void OnTriggerEnter(){
        Debug.Log ("game over");

    }
}

2015年2月4日 星期三

unity - popular API


Transform

Time

Random

Mathf


Coroutine


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

MonoBehaviour


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


2015年2月3日 星期二

unity - camera transform, rotate, movement follow a ball

using UnityEngine;
using System.Collections;

public class BallCamera : MonoBehaviour

    public Transform target;   //needed to drag a rigidboady to target


    public float relativeHeigth = 10.0f;


    public float zDistance = 5.0f;
    //×èÄáËÙ¶È
    public float dampSpeed = 2;

    void Update()
    {

        Vector3 newPos = target.position + new Vector3(0relativeHeigth, -zDistance);


        transform.position = Vector3.Lerp(transform.positionnewPosTime.deltaTime * dampSpeed);
    }
}


======

FOrum about camera movement
http://forum.unity3d.com/threads/wow-camera-movement.16949/

unity - rigidbody arrow control by Keyboard


The value will be in the range -1...1 for keyboard and joystick input.

        horizontalMovement = Input.GetAxis("Horizontal") * Vector3.right * movementSpeed;
        verticalMovement = Input.GetAxis("Vertical") * Vector3.forward * movementSpeed;


        Vector3 movement = horizontalMovement + verticalMovement;


        rigidbody.AddForce(movementForceMode.Force);

2015年1月29日 星期四

unity - rigidbody rotate

var eulerAngleVelocity : Vector3 = Vector3 (0, 100, 0);
 function FixedUpdate () {
  var deltaRotation : Quaternion = Quaternion.Euler(eulerAngleVelocity * Time.deltaTime);
  rigidbody.MoveRotation(rigidbody.rotation * deltaRotation);
 }

unity - rigidbody move

 http://docs.unity3d.com/ScriptReference/Rigidbody.MovePosition.html


private var speed : Vector3 = Vector3 (3, 0, 0);
 function FixedUpdate () {
  rigidbody.MovePosition(rigidbody.position + speed * Time.deltaTime);
 }

2015年1月27日 星期二

easy gravity example

1- drag a 3Dobject->cube into sense
2- add script on the right side, component
3- write the script





2015年1月18日 星期日