This commit is contained in:
corn
2026-06-07 22:59:32 +08:00
commit a62ff7379b
7171 changed files with 10015624 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
using UnityEngine;
namespace Unity.Advertisement.IosSupport.Samples
{
[ExecuteInEditMode]
public class AutoSwitchLayout : MonoBehaviour
{
public Transform portraitModeLayoutTransform;
public Transform landscapeModeLayoutTransform;
float m_PreviousAspectRatio;
private void Update()
{
var aspectRatio = 1f * Screen.width / Screen.height;
if (!Mathf.Approximately(aspectRatio, m_PreviousAspectRatio)
&& portraitModeLayoutTransform
&& landscapeModeLayoutTransform)
{
m_PreviousAspectRatio = aspectRatio;
if (aspectRatio > 1f)
{
landscapeModeLayoutTransform.gameObject.SetActive(true);
portraitModeLayoutTransform.gameObject.SetActive(false);
}
else
{
portraitModeLayoutTransform.gameObject.SetActive(true);
landscapeModeLayoutTransform.gameObject.SetActive(false);
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9c9a84136181c491fa22c727d7e4831a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,41 @@
using Unity.Advertisement.IosSupport.Components;
using UnityEngine;
using System;
using UnityEngine.iOS;
namespace Unity.Advertisement.IosSupport.Samples
{
/// <summary>
/// This component will trigger the context screen to appear when the scene starts,
/// if the user hasn't already responded to the iOS tracking dialog.
/// </summary>
public class ContextScreenManager : MonoBehaviour
{
/// <summary>
/// The prefab that will be instantiated by this component.
/// The prefab has to have an ContextScreenView component on its root GameObject.
/// </summary>
public ContextScreenView contextScreenPrefab;
void Start()
{
#if UNITY_IOS
// check with iOS to see if the user has accepted or declined tracking
// var status = ATTrackingStatusBinding.GetAuthorizationTrackingStatus();
Version currentVersion = new Version(Device.systemVersion);
Version ios14 = new Version("14.5");
// if (status == ATTrackingStatusBinding.AuthorizationTrackingStatus.NOT_DETERMINED && currentVersion >= ios14)
{
var contextScreen = Instantiate(contextScreenPrefab).GetComponent<ContextScreenView>();
// after the Continue button is pressed, and the tracking request
// has been sent, automatically destroy the popup to conserve memory
contextScreen.sentTrackingAuthorizationRequest += () => Destroy(contextScreen.gameObject);
}
#else
Debug.Log("Unity iOS Support: App Tracking Transparency status not checked, because the platform is not iOS.");
#endif
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5f0c6ccc637064b31981616bfc724dcb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,42 @@
using System;
using UnityEngine;
namespace Unity.Advertisement.IosSupport.Components
{
/// <summary>
/// This component controls an iOS App Tracking Transparency context screen.
/// You should only have one of these in your app.
/// </summary>
public sealed class ContextScreenView : MonoBehaviour
{
/// <summary>
/// This event will be invoked after the ContinueButton is clicked
/// and after the tracking authorization request has been sent.
/// It's a good idea to subscribe to this event so you can destroy
/// this GameObject to free up memory after it's no longer needed.
/// Once the tracking authorization request has been sent, there's no
/// need for this popup again until the app is uninstalled and reinstalled.
/// </summary>
public event Action sentTrackingAuthorizationRequest;
public void RequestAuthorizationTracking()
{
#if UNITY_IOS
Debug.Log("Unity iOS Support: Requesting iOS App Tracking Transparency native dialog.");
// ATTrackingStatusBinding.RequestAuthorizationTracking(AuthorizationTrackingReceived);
sentTrackingAuthorizationRequest?.Invoke();
#else
Debug.LogWarning("Unity iOS Support: Tried to request iOS App Tracking Transparency native dialog, " +
"but the current platform is not iOS.");
#endif
}
private void AuthorizationTrackingReceived(int status) {
Debug.LogFormat("Tracking status received: {0}", status);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 43c0833ba503546f1906839450d99850
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: