One: The script that controls the light:
public light alight;
alight = Gameobject.find ("The name of an object with a light"). Getcomponent<light> ();
The code above can pass the code information to the light component of the object.
ALight.light.intensity = a float number less than 8;//This will control the brightness of the light component.
Note that after this writing, in the Inspector panel options can not set the target for alight, otherwise it will error;
Two: Timer:
Public float Max =10.0f;//defines a maximum time
Void Update ()//detection at each frame
{
if (Max > 0.0f)
{
Max-= Time.deltatime;
}
Else
{
max=10.0f;
............
}
}//execute the Else code at every max time;
Three: Access to keyboard events
1. Press the event:
Input.getkeydown ();//If you press the key, return to Ture, otherwise return false
For example:
If (input. Getkeydown (KEYCODE.A))
{
Debug.log ("A key pressed");
}
2. Pick up the event:
Input.getkeyup ();//If you lift the button, return to Ture
For example:
If (input. Getkeyup (KEYCODE.A))
{
Debug.log ("Lift a Key");
}
3. Long press event:
Input.getkey ();
For example:
Int num=0;
If (input. GetKey (KEYCODE.A))
{
num++;
Debug.log ("A" was connected by "+num+");
}
Four: Loading a new scene
For example, a collider triggers the loading of a new scene:
Void Ontriggerenter (collider player)
{
Application.loadlevel ("scene name");
}
V: Export the game to a specific platform
1.file->buildsetting
2. Drag the built-in scene into the Scenes inbuild window to add, note the scene sort.
3. Click the Player setting button to set the game basic information in the Inspector panel, such as: Company name, game name, game icon. In the Per-platform setting option, ensure that the corresponding platform is correct, for the PC, can adjust the resolution, quality, full screen or not, and so on.
4. Click Build and run or build to save EXE files ...
VI: Baking light map
1. Set the static object to tell the system which objects are static in the scene.
Select the object and check the static in the Inspector panel.
2.windows->lightmapping (Light map)
In the object option, select the object that the baking is working on.
In the Bake option: mode, selecting the Duallightmaps system creates a vision and a close-up two-layer light map, and the mobile platform low-effect game can choose the use in forward rend option; At the bottom you can set the sky light.
In the MAPS option: Add light probes (ray detectors) to capture the lighting information in the scene and apply it to the dynamic object.
Create an empty object, select the object, Addcomponent->rendering->light probes
Then add Probe, the detector is arranged into the scene, the more detector layout, the better the sampling effect.
Back to the maps option, bake probes the detector to the scene, then back to the object option, changing the Bakeprobes to bake scene.
Delete the light from the scene after baking.
To make the probe effective for dynamic objects, select the Use light probes option for dynamic objects.
Seven: Animation production
Ctrl+6 or windows->animation Open the Animation editing window, create a new folder in the Resource folder to save the animation animation, select the object, click on the small red dots, you can record the animation;
Eight: Animation control (different states of the same character trigger different animations)
1. Create animation in 3ds max, export fbx format file, naming rule: Object name @ Animation name
2. Import the Fbx file into the Unity3d material folder and set the rig to legacy;
3. Drag the model into the scene, set the size to the number of animation segments you want to import in the Animations option, and then import the animation section below.
4. Write the script:
Animation.wrapmode = Wrapmode.loop; Set all animations to loop, there are other ways to set;
Play the animation code as:
Animation.play ("animated name");//No excessive playback of an animation;
Animation. Crossfade ("animated name"); Automatically transitions from the animation being played smoothly to the specified animation;
Unity Learning Note 3