文章目录
  1. 1. 2016-5-14
    1. 1.1. make 2d object glow when event fires
    2. 1.2. change opacity of GameObject
    3. 1.3. change opacity or something else frame by frame.
    4. 1.4. unity not support C# 6.0?
    5. 1.5. call function in another script of another gameobject
    6. 1.6. how to edit prefab?
    7. 1.7. MouseDown event not fire?
    8. 1.8. MouseDown event not fire after add one statement inside another object.
    9. 1.9. replace texture from jpg to png
    10. 1.10. replace pure color backgrounds as transparent?
    11. 1.11. move object gradually?
    12. 1.12. error “no model is available for preview” when previewing animation
    13. 1.13. make health bar in unity3d 5 (which is using new GUI system)
  2. 2. 2016-5-6
    1. 2.1. integrate git with unity 3d
    2. 2.2. cannot open script with VS2015.
    3. 2.3. showing Load ‘name’ (-1) couldn’t be loaded because it has not been added to the built settings
    4. 2.4. button to change scene programmatically
    5. 2.5. MonoBehaviour lifecycle
    6. 2.6. glow an object when mouse hover

2016-5-14

make 2d object glow when event fires

  • use shader to calculate glow shadow (very complex)
  • visible/invisible or change color of a substrate/glow layer

change opacity of GameObject

[GameObject].SetActive(false); another way is to disable renderer of that object.

change opacity or something else frame by frame.

Use animation. Don’t use code.

unity not support C# 6.0?

Yes, only C# 4.0 supported.

call function in another script of another gameobject

Just use the type of that script as a field, and bind with the gameobject which has this type of script as component.

how to edit prefab?

Some things you can add by clicking on the prefab and adding items using the Component menu. For more involved changes, drag the prefab into the scene, make whatever changes are necessary (ignore the message about breaking the prefab link), and when done, select Apply Changes to Prefab from the GameObject menu. Then delete the prefab from the scene.

Link

MouseDown event not fire?

Need Box Collider to detect this type of event.

MouseDown event not fire after add one statement inside another object.

Didn’t find why, however, set location at Start() workaround this issue, maybe it’s a bug.

replace texture from jpg to png

So far as I know, no way.

replace pure color backgrounds as transparent?

No way, do it in an image processing software.

move object gradually?

  1. Use iTween
  2. Set use

    1
    2
    3
    startPoint = CrewControl.transform.position;
    startTime = Time.time;
    endPoint = this.transform.position;

    Update use

    1
    2
    3
    4
    if (Time.time - startTime < duration)
    {
    CrewControl.transform.position = Vector3.Lerp(startPoint, endPoint, (Time.time - startTime) / duration);
    }

error “no model is available for preview” when previewing animation

Drag and drop the model source file into the animation preview window.

Link

make health bar in unity3d 5 (which is using new GUI system)

Add image inside panel, change its anchor to left (hold shift key), change scale programmatically

2016-5-6

integrate git with unity 3d

Edit -> Project Settings -> Editor. Set Version Control to meta files. Set Asset Serialization to force text.

Link

And download https://raw.githubusercontent.com/github/gitignore/master/Unity.gitignore

cannot open script with VS2015.

Detail can be found in editor.log located under C:\Users\xxx\AppData\Local\Unity\Editor\Editor.log Identified as a bug in community forum. Workaround is restart.

Found it may because last VS start failed and not close properly. Kill it in task manager first and try again.

showing Load ‘name’ (-1) couldn’t be loaded because it has not been added to the built settings

To add a level to the build settings use the menu File->Build Settings…

Link

button to change scene programmatically

  1. I add an empty game object. I attach my new script.

    1
    2
    3
    4
    public void NextLevelButton(string levelName)
    {

    SceneManager.LoadScene(levelName);
    }
  2. I associate this game object with my new script to the Button(in the inspector) by: Clicking the +(plus) button to add a callback from an object->script->method.

Link

MonoBehaviour lifecycle

http://docs.unity3d.com/Manual/ExecutionOrder.html

glow an object when mouse hover

get Renderer and change its material.color when OnMouseEnter/Over/Exit event Refer to http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseEnter.html

文章目录
  1. 1. 2016-5-14
    1. 1.1. make 2d object glow when event fires
    2. 1.2. change opacity of GameObject
    3. 1.3. change opacity or something else frame by frame.
    4. 1.4. unity not support C# 6.0?
    5. 1.5. call function in another script of another gameobject
    6. 1.6. how to edit prefab?
    7. 1.7. MouseDown event not fire?
    8. 1.8. MouseDown event not fire after add one statement inside another object.
    9. 1.9. replace texture from jpg to png
    10. 1.10. replace pure color backgrounds as transparent?
    11. 1.11. move object gradually?
    12. 1.12. error “no model is available for preview” when previewing animation
    13. 1.13. make health bar in unity3d 5 (which is using new GUI system)
  2. 2. 2016-5-6
    1. 2.1. integrate git with unity 3d
    2. 2.2. cannot open script with VS2015.
    3. 2.3. showing Load ‘name’ (-1) couldn’t be loaded because it has not been added to the built settings
    4. 2.4. button to change scene programmatically
    5. 2.5. MonoBehaviour lifecycle
    6. 2.6. glow an object when mouse hover