Unityで3Dモデルを小さくする方法
1:一度に 縮小・拡大する
Unity - Scripting API: Transform.localScale
transform.localScale += new Vector3(0.1F, 0, 0);
How to make a script enlarge a character. - Unity Answers
// C#
transform.localScale = new Vector3(transform.localScale.x * 2, transform.localScale.y * 2, transform.localScale.z * 2);
// JS
transform.localScale = Vector3(transform.localScale.x * 2, transform.localScale.y * 2, transform.localScale.z * 2);
2:だんだんと縮小・拡大させる
シンプル: Error | Unity Community
例:
How do I Scale a GameObject over time? - Unity Answers
他:
How to gradually grow and shrink an object - Unity Answers
How to increase and decrease object scale over time? - Unity Answers
gradually shrinking an object - Unity Answers
----例----
using UnityEngine;
using System.Collections;
public class FlowerShrinkScript_C : MonoBehaviour
{
public float targetScale = 0.1f;
public float shrinkSpeed = 0.001f;
public bool shrinking = false;
// Use this for initialization
void Start ()
{
shrinking = true;
}
// Update is called once per frame
void Update ()
{
if (transform.localScale.x > targetScale) {
transform.localScale -= new Vector3 (shrinkSpeed, shrinkSpeed, 0);
}
}
}