Unity-3d Day07

Source: Internet
Author: User

Component communicating with the script:

Component Law:
Getcomponent ();
Getcomponent<type> ();
Getcomponent ("Type");

// !!!!!! Strong turn must be variable to receive!!!!!!!         // returns the component type, with the as strong turn        Transform T1 = getcomponent (typeof as Transform;         // using generics (Common way)        Transform t2 = getcomponent<transform>();         // use name to get        Transform t3 = getcomponent ("Transform" as Transform;



What is the main thing?: Getting the components of a game object and its objects

Getcomponent If the game object has an append, it returns the type of the component, or null if not.
Getcomponentinchildren returns the type component, in Gameobject or any of its objects, to make depth-first search, returning only the active component.
Getcomponents returns all type components in the game object.
Getcomponentsinchildren in Gameobject or any of its? objects, return all type components

AddComponent Law:
Add a component to a game object
Note: There is no Romovecomponent method to remove components? Object.destroy ()

SendMessage Law:
SendMessage to search all monobehaviour of the current game object with the name MethodName?
Sendmessageupwards Search all Monobehaviour in the current game object and its object for the name MethodName?
Broadcastmessage Search all Monobehaviour in the current game object and its object for the name MethodName?

Next is the animation aspects of the animation component, the old version of the basic is not used, but still want to know about it.
Animation kai? " The default animation that will play when playing "play automatically"
Animations can be accessed from a script? series animations
Play automatically should I play animation when I start the game?
When Animate Physics is turned on, the animation will be in the physical loop. Only when combined with a kinematic rigid body?
Culling Type determines when the animation is not played

Animation. Properties:
Animatephysics is true when the animation is in the physical loop, when combined with a kinematic rigid body?
Clip default animation? segment
Cullingtype blanking type: alwaysanimate, Basedonrenderers,
Basedonclipbounds, Basedonuserbounds
Whether the isplaying is playing
Localbounds animation component at the boundary of the local space, refer to the bounds type
Playautomatically the real time? Motion play
This[string] Returns the animation state of a segment
WrapMode Animation Cycle Mode

Animation Composition Framework:

Animation often?? Method:

Animationclip Class Properties:
The degree of the length animation in seconds (read only)
Framerate sampled keyframe frame rate (read-only)
WrapMode the default looping mode that is set in the animation state.
The Localbounds animation component is also attached to this animated clip in the local coordinate space.

Animationclip class? Method:
Setcurve assign a curve to an animation? Special properties
Clearcurves Clear all curves from a clip
Addevent adding animated events to a clip
Setcurve function:
Setcurve (relativepath:string, Type:type, propertyname:string, Curve:animationcurve);

RelativePath should give the curve the path of the game object. RelativePath are formatted similar paths, such as "Root/spine/leftarm". If RelativePath is empty, table? Animated clips are attached to the game object.
Type of the class of the component being animated
PropertyName the name or path of the property being animated
Curve Animation curve

Today is a lot of things, but better is not to be used later, to understand the can I also omitted a lot of ...

On the code:

usingUnityengine;usingSystem.Collections; Public classAnimationscript:monobehaviour {//Use this for initialization    voidStart () {Animation Anim =animation; //Create an animated clipAnimationclip clip =NewAnimationclip (); //Create an animation curveAnimationcurve curve =Animationcurve.linear (0f, 1f, 5f, 100f); //Animationcurve curve = new Animationcurve ();curve.        Addkey (0f, 1f); Curve.        Addkey (1f, 5f); Curve.        Addkey (2f, 0f); Clip. Setcurve ("",typeof(Transform),"localposition.x", Curve); Clip. Setcurve ("",typeof(Transform),"LOCALPOSITION.Y", Curve); Clip. Setcurve ("",typeof(Transform),"localposition.z", Curve); Animationevent animevent=Newanimationevent (); Animevent.time=2f; Animevent.functionname="playscaleanimation"; Animation. Addclip (clip,"hehe"); Animation. Play ("hehe"); }        //Update is called once per frame    voidUpdate () {}//The method is triggered when the animation is executed to the Insert event location     Public voidplayscaleanimation () {animation. Play ("scaleanimation"); }}

usingUnityengine;usingSystem.Collections; Public classCubescript:monobehaviour {//Use this for initialization    voidStart () {stringName = Getcomponentinchildren<animationscript>(). Name; component[] COMs= getcomponentsinchildren<animationscript>(); foreach(varIteminchcoms)        {print (item.name); }    }        //Update is called once per frame    voidUpdate () {//transform. Rotatearound (Vector3.zero, Vector3.back, 1000f * time.time);        if(Input.getkeydown (keycode.space)) {animation.        Play (); }            }}

Well, there's too many things to remember this day.

These two days want to write a decent point of the project will not write small projects in a few days written well together to send Goodnight,, the world

Unity-3d Day07

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.