Programming」カテゴリーアーカイブ

プログラミング全般に関するカテゴリーです。

Time.timeScale=0でもiTweenを使う方法

UnityではTime.timeScale01未満の値に設定することで、ゲームの一時停止やスローモーション状態を簡単に作ることができます。ただ、ゲームは停止中でもiTweenを使ったUIアニメーションだけは動かしたいという場面もあると思います。そういう場合はignoretimescaleのプロパティーを使うと良いそうです。

使い方は次のような感じです。

Hashtable ht = new Hashtable ();
ht.Add ("from", 0.0f);
ht.Add ("to", 1.0f);
ht.Add ("ignoretimescale", true);
ht.Add ("onupdate", "myOnUpdateFunction");
iTween.MoveTo(gameObject, ht);

リンク

iTween Ignore Scale Time | Unity Community
https://forum.unity.com/threads/itween-ignore-scale-time.175926/

忍者AdMaxがUnityに対応

サムライファクトリーのSSP(Supply Side Platform)がUnityにも対応しました。

Unity製アプリに最速で広告を実装
忍者AdMaxを始める (adf.shinobi.jp)

Unityでのアプリ広告掲載フローは以下の通りです。

  1. 忍者ツールズに新規ユーザー登録後、忍者AdMaxのサービスを追加
  2. AdMaxSDK Unity Pluginをインポートして、Prefabを追加

AdMaxSDK.unitypackageは以下のページからダウンロード可能です。

GitHub – ninjatools/admax-unity-plugin: AdMaxSDKをUnityで簡単に使えるようにしたプラグインです。
https://github.com/ninjatools/admax-unity-plugin (配布終了しました → 関連記事

Unityアプリだけでなく、ブログやホームページでの広告にも対応しています。

GoogleのAdMob/AdSenseと比べても手続きが簡単なので、とりあえず登録&試してみてもいいかなと思います。


忍者AdMaxでアプリのマネタイズ

UnityのMaterialのTilingやOffsetの値をスクリプトから変更する方法

SetTextureOffsetSetTextureScaleを使うことで、MaterialのTilingやOffsetの値を変更できるようです。

使い方は次のような感じです。

Renderer renderer = GetComponent<Renderer> ();

Vector2 offset = new Vector2(...);
Vector2 scale = new Vector2(...);

renderer.material.SetTextureOffset("_MainTex", offset);
renderer.material.SetTextureScale("_MainTex", scale);
renderer.material.SetTextureOffset("_BumpMap", offset);
renderer.material.SetTextureScale("_BumpMap", scale);

リンク

How to change Tiling / Offset of all generated Textures by script?
https://forum.allegorithmic.com/index.php?topic=3077.0