code ソーシャル

Unityアプリcodetips(38)

スポンサーリンク

一旦統合作業に入ります。

//tips

//関数がきちんと作動しているかの確認

動作の確認方法としてDebug.Logを使いこなすことが重要で、下記のスクリプトのVector3.Lerpがうまく機能していない場合にはDebug.LogにてVector3.Lerpの要素を確認することで状況を把握できる。

Debug.Log(startMarker.position + " " + endMarker.position + " " + present_Location);

(-13.7, 0.0, -38.7) (0.0, 0.0, -38.7) 0.3439157
UnityEngine.Debug:Log(Object)
Liner:Update() (at Assets/script/StageSelect/Liner.cs:32)

(-13.7, 0.0, -38.7) (0.0, 0.0, -38.7) 0.346985
UnityEngine.Debug:Log(Object)
Liner:Update() (at Assets/script/StageSelect/Liner.cs:32)

・・・

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Liner : MonoBehaviour
{

public RectTransform startMarker;
public RectTransform endMarker;

// スピード
public float speed = 1000.0F;

//二点間の距離を入れる
private float distance_two;

void Start()
{
//二点間の距離を代入(スピード調整に使う)
distance_two = Vector3.Distance(startMarker.position, endMarker.position);
}

void Update()
{

// 現在の位置
float present_Location = (Time.time * speed) / distance_two;
Debug.Log(startMarker.position + " " + endMarker.position + " " + present_Location);

// オブジェクトの移動
transform.position = Vector3.Lerp(startMarker.position, endMarker.position, present_Location);
}
}

//シーンimageのfadeスクリプトを考える

Gameoverシーンの演出を変更するため画面移行をInvoke("GameOver", 10.0f);と遅くし、演出に時間をかけられるようにする。

ガラスが割れるエフェクトを実装しようと思ったがblenderを使用する必要があるようなので今回は保留にする。ストレージに問題がなくなったら実行する。

参考エフェクトとして下記のスクリプトを背景イメージにアタッチする。Isfadeをチェックし、time=2とした。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Fade : MonoBehaviour
{
bool IsFadeOut;//フェードアウトをするかどうか
public bool IsFade;//フェードの演出をするかどうか
public float time;//フェードにかかる時間
Image image;
void Start()
{
image = this.GetComponent<Image>();
}

void Update()
{
if (IsFade)
{
if (IsFadeOut)
{
//フェードアウトの処理
if (image.color.a < 1) image.color = new Color(0, 0, 0, image.color.a + 1 / (60 * time));
else image.color = new Color(0, 0, 0, 1);
}
else
{
//フェードインの処理
if (image.color.a >= 0) image.color = new Color(0, 0, 0, image.color.a - 1 / (60 * time));
else image.color = new Color(0, 0, 0, 0);
}
}
}

public void StartFade(float t, bool fadeout)
{
time = t;
IsFadeOut = fadeout ? true : false;
if (IsFadeOut) image.color = new Color(0, 0, 0, 0);
else image.color = new Color(0, 0, 0, 1);
IsFade = true;
}
}

変更するのは透明度aだけで良いので下記のようにスクリプトを変更した。
徐々にimageを実体化させている。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Fade : MonoBehaviour
{

public float time;
public float speed = 40.0f;
Image image;
void Start()
{
image = this.GetComponent<Image>();
}

void Update()
{

//フェードインの処理
if (image.color.a >= 0)
{
image.color = GetAlphaColor(image.color);
}
}

Color GetAlphaColor(Color color)
{
time += Time.deltaTime * 5.0f * speed;
// color.a = Mathf.Sin(time) * 0.1f + 0.5f;
color.a = time/100 + 0.01f;
return color;
}
}

//canvasのimageとparticle systemを併用する

canvas内にparticle systemを設置し、particle systemのorder in layerをcanvasのorder in layerより大きくすることでparticleがcanvasより手前に描画される。

particleの色はStart colorから変更することが可能。大きさはStart sizeで変更。

//unityアセットストアのExtension Assetについて

再度無料Extension AssetであるSpace Robot Kyleは、app storeに公開するアプリ内のキャラクターとして使用できるのかを確認した。

free Extension Asset(One license required for each individual use)という謎なカテゴリーになっているが規約に基づくと一人で作成する場合はエンドユーザーにアセットの抜き出しが不可能な形でアプリデータを納品すれば問題はなさそうである。

https://support.unity3d.com/hc/en-us/articles/208601846-A-package-I-want-to-purchase-on-the-Asset-Store-says-Extension-Asset-One-license-required-for-each-individual-user-under-the-License-section-What-does-this-mean-

https://answers.unity.com/questions/1711324/do-i-need-a-license-for-a-free-extension-asset.html

https://unity3d.com/jp/legal/as_terms

http://assetstore.info/notice/eulamodify20200203/

https://helpdesk.unity3d.co.jp/hc/ja/articles/900000789966-%E5%88%A9%E7%94%A8%E8%A6%8F%E7%B4%84-%E4%BD%BF%E7%94%A8%E8%A8%B1%E8%AB%BE%E3%81%AB%E5%9F%BA%E3%81%A5%E3%81%8F%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88%E3%81%AE%E3%83%A9%E3%82%A4%E3%82%BB%E3%83%B3%E3%82%B9%E7%A8%AE%E5%88%A5%E3%82%92%E7%9F%A5%E3%82%8A%E3%81%9F%E3%81%84

 

 

人気の記事

1

皆さん、ついに、エアラインでも、サブスクリプションが始まったのはご存じですか? まだ実験段階ですが、ANAが、定額全国住み放題サービスを提供する「ADDress」と組んで、国内線を4回まで定額利用可能 ...

2

無料でネットショップを開けるアプリとして多くの人に驚きを与えたBASE株式会社が、2019年10月25日東証マザーズに上場しました。2020年2月時点で90万店を超えるショップを抱えるまでに成長してい ...

3

2011年にサービスを開始してから圧倒的な成長率を誇るインテリア通販サイト 【FLYMEe/フライミー】を皆さんご存じでしょうか。 「自分のイメージするインテリア、本当に欲しいインテリアがどこにあるの ...

4

ついに、noteの月間アクティブユーザー数が4400万人(2020年3月時点)に到達しました。 そもそも、「note」とは、クリエイターが、文章やマンガ、写真、音声を投稿することができ、ユーザーはその ...

5

ボードゲームカフェが1日2回転で儲かるという記事をみつけたので興味を持ち、調べてみました。 まずは、需要がどれくらいあるのか、市場のようすからみていきましょう。 世界最大のボードゲーム市場はドイツで、 ...

-code, ソーシャル
-,

Copyright© BUSINESS HUNTER , 2023 All Rights Reserved Powered by AFFINGER5.