//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()
導入している機能同士の混線または負荷の重さが要因だろうか。要検証。