コード例 #1
0
 void Start()
 {
     Debug.Log("WeatherSystem Start " + name);
     lightingBolt         = GetComponent <LightingBolt> ();
     lightingBolt.enabled = weatherType == WeatherType.Rain || weatherType == WeatherType.Heavy_Rain;
     OnStart();
 }
コード例 #2
0
ファイル: DemoScript.cs プロジェクト: chinafuqh/UnityX
    public void CreatePooledBolt(Vector2 source, Vector2 dest, Color color, float thickness)
    {
        //如果闪电池中有非激活的闪电则取出
        if (inactiveBoltsObj.Count > 0)
        {
            //取出GameObject
            GameObject boltObj = inactiveBoltsObj[inactiveBoltsObj.Count - 1];

            //设为激活
            boltObj.SetActive(true);

            //加入avtive list
            activeBoltsObj.Add(boltObj);
            inactiveBoltsObj.RemoveAt(inactiveBoltsObj.Count - 1);

            //获取bolt组件
            LightingBolt boltComponent = boltObj.GetComponent <LightingBolt>();

            //用给定的位置数据激活闪电
            boltComponent.ActivateBolt(source, dest, color, thickness);
            boltComponent.Draw();
        }
    }