コード例 #1
0
        //!
        //! Use this for initialization
        //!
        void Start()
        {
            target = this.transform;

            //initalize cached references
            serverAdapter = GameObject.Find("ServerAdapter").GetComponent <ServerAdapter>();



            //update initial parameters
            initialPosition = target.position;
            initialRotation = target.rotation;
            initialScale    = target.localScale;

            lastPosition = initialPosition;
            lastRotation = initialRotation;



            animatorObject = transform.GetComponent <AnimatorObject>();
            if (animatorObject == null)
            {
                animatorObject = transform.parent.GetComponent <AnimatorObject>();
            }
        }
コード例 #2
0
ファイル: UI_Base.cs プロジェクト: vic910/ChessSoul
 /// <summary>
 ///     播放进入动画
 /// </summary>
 public virtual void PlayEntranceAnimation()
 {
     if (AnimatorObject == null)
     {
         return;
     }
     AnimatorObject.CrossFade("Base Layer.Entrance", 0f, 0, 0f);
 }
コード例 #3
0
ファイル: UI_BaseToLua.cs プロジェクト: vic910/ChessSoul
 /// <summary>
 /// 播放退出动画
 /// </summary>
 public override void PlayExitAnimation()
 {
     if (AnimatorObject == null)
     {
         return;
     }
     AnimatorObject.CrossFade("Base Layer.Exit", 0f, 0, 0f);
 }
コード例 #4
0
        //!
        //! Use this for initialization
        //!
        void Start()
        {
            if (transform.childCount > 0)
            {
                lightTarget = transform.GetChild(0);
                if (lightTarget != null)
                {
                    sourceLight = lightTarget.GetComponent <Light>();
                }
            }


            if (sourceLight)
            {
                target = this.transform;

                initialLightColor     = sourceLight.color;
                initialLightColor.a   = 0.25f;
                initialLightIntensity = sourceLight.intensity;

                if (sourceLight.type == LightType.Directional)
                {
                    isDirectionalLight = true;
                    lightGeo           = lightTarget.Find("Arrow");
                }
                else if (sourceLight.type == LightType.Spot)
                {
                    isSpotLight       = true;
                    initialLightRange = sourceLight.range;
                    initialSpotAngle  = sourceLight.spotAngle;
                    lightGeo          = lightTarget.Find("Cone");
                }
                else if (sourceLight.type == LightType.Point)
                {
                    isPointLight      = true;
                    initialLightRange = sourceLight.range;
                    lightGeo          = lightTarget.Find("Sphere");
                }
            }
            else
            {
                target = this.transform;
            }

            //initalize cached references
            serverAdapter = GameObject.Find("ServerAdapter").GetComponent <ServerAdapter>();


            //cache Reference to animation data
            animData = AnimationData.Data;

            //update initial parameters
            initialPosition = target.position;
            initialRotation = target.rotation;
            initialScale    = target.localScale;

            lastPosition = initialPosition;
            lastRotation = initialRotation;


            //generate colliding volumes
            if (generateBoxCollider)
            {
                //calculate bounds
                bounds = new Bounds(Vector3.zero, Vector3.zero);


                bool       hasBounds = false;
                Renderer[] renderers = this.gameObject.GetComponentsInChildren <Renderer>();
                foreach (Renderer render in renderers)
                {
                    if (!sceneLoader.isEditable(render.gameObject) || render.gameObject == this.gameObject)
                    {
                        if (hasBounds)
                        {
                            bounds.Encapsulate(render.bounds);
                        }
                        else
                        {
                            bounds    = render.bounds;
                            hasBounds = true;
                        }
                    }
                }

                BoxCollider col = this.gameObject.AddComponent <BoxCollider>();

                // TODO: temporary
                col.isTrigger = true; // not interacting



                if (sourceLight)
                {
                    // BoxCollider col_lightquad = lightTarget.FindChild("LightQuad").GetComponent<BoxCollider>();
                    // col.size = col_lightquad.size;
                    // col.center = col_lightquad.center;
                    col.isTrigger = true; // not interacting
                    LightIcon iconScript = lightTarget.Find("LightQuad").GetComponent <LightIcon>();
                    iconScript.TargetCollider = col;
                    iconScript.TargetScale    = target.lossyScale; // target.localScale;
                }
                else
                {
                    col.center              = new Vector3((bounds.center.x - this.transform.position.x) / this.transform.lossyScale.x, (bounds.center.y - this.transform.position.y) / this.transform.lossyScale.y, (bounds.center.z - this.transform.position.z) / this.transform.lossyScale.z);
                    col.size                = new Vector3(bounds.size.x / this.transform.lossyScale.x, bounds.size.y / this.transform.lossyScale.y, bounds.size.z / this.transform.lossyScale.z);
                    col.material            = new PhysicMaterial();
                    col.material.bounciness = 1.0f;
                }

                //target.position = initialPosition;
                // target.localScale = initialScale;
                // target.rotation = initialRotation;
            }
            if (!isDirectionalLight && !isPointLight && !isSpotLight && this.name != "camera")
            {
                this.gameObject.AddComponent <Rigidbody>();
                this.gameObject.GetComponent <Rigidbody>().mass = 100.0f;
                this.gameObject.GetComponent <Rigidbody>().drag = 2.5f;


                // TODO: temporary
                this.gameObject.GetComponent <Rigidbody>().useGravity = false;
            }


            // get animator object to trigger mocap anims
            animatorObject = transform.GetComponent <AnimatorObject>();
            if (animatorObject == null)
            {
                animatorObject = transform.parent.GetComponent <AnimatorObject>();
            }
        }