Skip to content

Instantly share code, notes, and snippets.

View superbderrick's full-sized avatar
🎯
Focusing

Derrick superbderrick

🎯
Focusing
View GitHub Profile
this.rewardedAd.OnPaidEvent += this.HandleAdPaidEvent;
public void HandleAdPaidEvent(object sender, AdValueEventArgs args)
{
AdValue adValue = args.AdValue;
Firebase.Analytics.Parameter[] LTVParameters = {
new Firebase.Analytics.Parameter("valuemicros", adValue.Value),
new Firebase.Analytics.Parameter("currency", adValue.CurrencyCode),
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine.UI;
using UnityEngine;
#if UNITY_IOS || UNITY_TVOS
public class NativeAPI {
[DllImport("__Internal")]
#import <Foundation/Foundation.h>
#import "NativeCallProxy.h"
@implementation FrameworkLibAPI
id<NativeCallsProtocol> api = NULL;
+(void) registerAPIforNativeCalls:(id<NativeCallsProtocol>) aApi
{
api = aApi;
// [!] important set UnityFramework in Target Membership for this file
// [!] and set Public header visibility
#import <Foundation/Foundation.h>
// NativeCallsProtocol defines protocol with methods you want to be called from managed
@protocol NativeCallsProtocol
@required
- (void) loadedUnity:(NSString*)status;
// other methods
func initUnity() {
if let nativeWindow = self.window {
if unityIsInitialized() {
UnitySampleUtils.showAlert(Constants.ERRORMESSAGES.ALREADY_INIT, Constants.ERRORMESSAGES.UNLOAD_FIREST, window: nativeWindow)
return
}
if didQuit {
UnitySampleUtils.showAlert(Constants.ERRORMESSAGES.CANNOTBE_INITIALIZED, Constants.ERRORMESSAGES.USE_UNLOAD, window:nativeWindow)
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import <Foundation/Foundation.h>
#include <UnityFramework/UnityFramework.h>
#include <UnityFramework/NativeCallProxy.h>
import UIKit
import UnityFramework
@main
class AppDelegate: UIResponder, UIApplicationDelegate, UnityFrameworkListener , NativeCallsProtocol {
func showHostMainWindow(_ color: String!) {
if(color == Constants.COLOR.BLUE) {
self.unitySampleView.nativeTitleLable.backgroundColor = .red
self.unitySampleView.nativeTitleLable.textColor = .white
} else if(color == Constants.COLOR.RED) {
[UnityFrameworkLoad() unloadApplication];
- (void)unityDidUnload:(NSNotification*)notification
{
[[self ufw] unregisterFrameworkListener: self];
[self setUfw: nil];
}
(void)initUnity
{
[self setUfw: UnityFrameworkLoad()];
[[self ufw] setDataBundleId: "com.unity3d.framework"];
[[self ufw] registerFrameworkListener: self];
[NSClassFromString(@"FrameworkLibAPI") registerAPIforNativeCalls:self];
[[self ufw] runEmbeddedWithArgc: gArgc argv: gArgv appLaunchOpts: appLaunchOpts];
}
@superbderrick
superbderrick / stack.kt
Created October 31, 2021 06:03
kotlin stack
class MutableStack<E>(vararg items: E) { // 1
private val elements = items.toMutableList()
fun push(element: E) = elements.add(element) // 2
fun peek(): E = elements.last() // 3
fun pop(): E = elements.removeAt(elements.size - 1)