code ソーシャル

Unityアプリcodetips(70)

スポンサーリンク

//tips

//負荷が少ないステージのgoal時のinvoke1秒が長く感じられる

初期ステージのゴール時点でinvokeの1秒が長く感じられるのでゴール音を追加する。

GoalオブジェクトにaudioSourceコンポーネントをアタッチし、GoalControllerを編集する。

Volumeは0.3程度まで落とした。pitchをmaxにして再生速度を早めた。

https://gametukurikata.com/se/sound

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class GoalController : MonoBehaviour
{
[SerializeField] GameObject Fade;

GameObject Player;

public int stageNo;

public int clearlevel;
public int nowlevel;

public AudioClip sound1;
AudioSource audioSource;

void Start()
{

this.Player = GameObject.Find("Player");
clearlevel = PlayerPrefs.GetInt("LEVEL", 0);//easy0,hard1,hell2
int nowlevel = PlayerPrefs.GetInt("nowLEVEL", 0);

audioSource = GetComponent<AudioSource>();

}

void Update()
{

Vector3 p1 = transform.position;
Vector3 p2 = this.Player.transform.position;

 

if (p1 == p2)
{
Fadeover();
audioSource.PlayOneShot(sound1);

if (Player != null)
{
Invoke("Goal", 1.0f);

}
}

}

void Goal()
{
if (clearlevel == 0)
{
if (PlayerPrefs.GetInt("CLEAR,0") < stageNo)
{
PlayerPrefs.SetInt("CLEAR", stageNo);
}
}

if(clearlevel ==1)
{
if (PlayerPrefs.GetInt("CLEARhd,0") < stageNo)
{
PlayerPrefs.SetInt("CLEARhd", stageNo);
}

}
if (clearlevel == 2)
{
if (PlayerPrefs.GetInt("CLEARhl,0") < stageNo)
{
PlayerPrefs.SetInt("CLEARhl", stageNo);
}

}

SceneManager.LoadScene("Goal");
}
void Fadeover()
{
Fade.SetActive(true);
}

}

 

//shareボタンクリック時、capture画像が真っ暗になる

Nativeshareで作成したshareボタンクリック時、capture画像が真っ暗になるのでcrownシーン調整を行う。

コルーチンのWaitForEndOfFrame部分でinvokeの時間までスキップしてしまうのかと思ったが、それは違うよう。

わざわざcrownシーンに時間経過処理を入れる必要もないので、念のためinvokeをなくして、画面タップでもとのシーンに戻れるようにする。

透明化したボタンに下記スクリプトをアタッチ。

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

public class CrownBackScene : MonoBehaviour
{

public void PushCrownBack()
{
int nowlevel = PlayerPrefs.GetInt("nowLEVEL", 0);

if (nowlevel == 0)
{
SceneManager.LoadScene("StageSelect");
}
if (nowlevel == 1)
{
SceneManager.LoadScene("StageSelecthard");
}
if (nowlevel == 2)
{
SceneManager.LoadScene("StageSelecthell");
}

}
}

Xcodeのinfoでキャプチャーimage保存を可能にしているかチェックしたところ、こちらも機能している。

https://github.com/yasirkula/UnityNativeShare/wiki/Manual-Setup-for-iOS

異なるシーンにshareボタンを設け、異なるsnsおよびメール、airdropでも確認したが全て真っ黒。

別のプロジェクトでsnsをシェアするシーンだけを作成したところきちんと機能する。

Portraitなどの縦横の表示の設定が影響を与えるかと思ったが、問題なく表示される。

Canvasをconstant pixel sizeに変更、さらに3Dオブジェクトを画面描写内部に入れて検証。

こちらも問題ない。

Native share をアンインストールして、再度インストールし直しても効果なし。

Xcodeのreportで下記のように示された。

CrownManager:Start()

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Metal: Cannot read pixels from write-only backbuffer. Uncheck 'Metal Write-Only Backbuffer' in PlayerSettings.
(Filename: Line: 55)

2020-09-26 20:30:13.776911+0900 original[2087:708543] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x2809e7ed0 _UIActivityActionCellTitleLabel:0x11507e350.height >= 22 (active)>",
"<NSLayoutConstraint:0x2809e6ee0 V:|-(15)-[_UIActivityActionCellTitleLabel:0x11507e350] (active, names: '|':UIView:0x11507fb80 )>",
"<NSLayoutConstraint:0x2809e77a0 V:[_UIActivityActionCellTitleLabel:0x11507e350]-(15)-| (active, names: '|':UIView:0x11507fb80 )>",
"<NSLayoutConstraint:0x2809ed6d0 'UIView-Encapsulated-Layout-Height' UIView:0x11507fb80.height == 50.3333 (active)>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x2809e7ed0 _UIActivityActionCellTitleLabel:0x11507e350.height >= 22 (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2020-09-26 20:30:40.034986+0900 original[2087:708543] [core] SLRemoteComposeViewController: (this may be harmless) viewServiceDidTerminateWithError: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method}
2020-09-26 20:30:40.535805+0900 original[2087:708543] Shared to com.apple.UIKit.activity.PostToTwitter with result: 0
2020-09-26 20:30:41.931623+0900 original[2087:708543] Shared to (null) with result: 0
2020-09-26 20:30:41.931419+0900 original[2087:708764] [ShareSheet] connection invalidated
-> applicationWillResignActive()
-> applicationDidEnterBackground()

導入している機能同士の混線または負荷の重さが要因だろうか。要検証。

 

 

 

 

人気の記事

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.