Code Monkey home page Code Monkey logo

rnunity's Introduction

GithubThumbnail

Hi there 👋

I'm Rushit from India, and I do content on Development and Design. I'm a developer that loves simplifying things. I love breaking down complex problems into simple, easy to understand solutions. I really enjoy building Mobile application and Web Applications that grow your product in a better manner.


⚒️  Tech Stack:

While I don't stick to a specific stack, here are some things I have worked with recently:

📱  Mobile:  React Native StyledComponents CodePush Expo

🖥️  Web:  React StyledComponents

🧮  Backend:  PHP Node.js

ℹ️  Database:  MySQL MongoDB

🎨  Design:  AdobeXD Figma

⚙️  Version Control and CI/CD pipelines:  Git GitHub


Feel free to visit my website rushitjivani.netlify.app to explore some of my recent projects and find more about me.

I'm open to full-time opportunities where I can contribute, learn and grow. If you have a good opportunity that matches my skills and experience then feel free to contact me on my Linkedin or my Website.


Stats

Rushit Jivani's GitHub stats


Connect with me:

👨‍💼 Linkedin

🌎 Website

rnunity's People

Contributors

rushit013 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

rnunity's Issues

No such module 'UnityFramework'

I have created the swift file name---->>>UnityEmbeddedSwift.swift
for this file i have added the code

//
// UnityEmbeddedSwift.swift
// RNUnity
//
// Created by MAC on 22/08/23.
//

import Foundation
import UnityFramework

class UnityEmbeddedSwift: UIResponder, UIApplicationDelegate, UnityFrameworkListener {

private struct UnityMessage {
    let objectName : String?
    let methodName : String?
    let messageBody : String?
}

static var applicationList = String

static var instance : UnityEmbeddedSwift!
private var ufw : UnityFramework!
private static var hostMainWindow : UIWindow! // Window to return to when exiting Unity window
private static var launchOpts : [UIApplication.LaunchOptionsKey: Any]?

private static var cachedMessages = [UnityMessage]()

override init() {
UnityEmbeddedSwift.hostMainWindow = UIApplication.shared.windows.first { $0.isKeyWindow }

}
@objc func appMovedToBackgroundMain() {
print("main - App moved to Background!")
ufw.appController()
}
// MARK: - Static functions (that can be called from other scripts)

static func getUnityRootViewController() -> UIViewController! {
    return instance.ufw.appController()?.rootViewController
}

static func getUnityView() -> UIView! {
    return instance.ufw.appController()?.rootViewController?.view
}

@objc static func setHostMainWindow(_ hostMainWindow : UIWindow?) {
UnityEmbeddedSwift.hostMainWindow = hostMainWindow
let value = UIInterfaceOrientation.landscapeLeft.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
}

@objc static func setLaunchinOptions(_ launchingOptions : [UIApplication.LaunchOptionsKey: Any]?) {
UnityEmbeddedSwift.launchOpts = launchingOptions
}

static func showUnity() {
    if(UnityEmbeddedSwift.instance == nil || UnityEmbeddedSwift.instance.unityIsInitialized() == false) {
        UnityEmbeddedSwift().initUnityWindow()
    }
    else {
        UnityEmbeddedSwift.instance.showUnityWindow()
    }

}

static func hideUnity() {
    UnityEmbeddedSwift.instance?.hideUnityWindow()
}

static func pauseUnity() {
    UnityEmbeddedSwift.instance?.pauseUnityWindow()
}

static func unpauseUnity() {
    UnityEmbeddedSwift.instance?.unpauseUnityWindow()
}

static func unloadUnity() {
    UnityEmbeddedSwift.instance?.unloadUnityWindow()
}

static func sendUnityMessage(_ objectName : String, methodName : String, message : String) {
    let msg : UnityMessage = UnityMessage(objectName: objectName, methodName: methodName, messageBody: message)

    // Send the message right away if Unity is initialized, else cache it
    if(UnityEmbeddedSwift.instance != nil && UnityEmbeddedSwift.instance.unityIsInitialized()) {
        UnityEmbeddedSwift.instance.ufw.sendMessageToGO(withName: msg.objectName, functionName: msg.methodName, message: msg.messageBody)
    }
    else {
        UnityEmbeddedSwift.cachedMessages.append(msg)
    }
}

// MARK - Callback from UnityFrameworkListener

func unityDidUnload(_ notification: Notification!) {
    ufw.unregisterFrameworkListener(self)
    ufw = nil
    UnityEmbeddedSwift.hostMainWindow?.makeKeyAndVisible()
}

// MARK: - Private functions (called within the class)

private func unityIsInitialized() -> Bool {
    return ufw != nil && (ufw.appController() != nil)
}

private func initUnityWindow() {
    if unityIsInitialized() {
        showUnityWindow()
        return
    }

    ufw = UnityFrameworkLoad()!
    ufw.setDataBundleId("com.unity3d.framework")
    ufw.register(self)

// NSClassFromString("FrameworkLibAPI")?.registerAPIforNativeCalls(self)

    ufw.runEmbedded(withArgc: CommandLine.argc, argv: CommandLine.unsafeArgv, appLaunchOpts: UnityEmbeddedSwift.launchOpts)

    sendUnityMessageToGameObject()

    UnityEmbeddedSwift.instance = self
}

private func showUnityWindow() {
    if unityIsInitialized() {
        ufw.showUnityWindow()
        sendUnityMessageToGameObject()
    }
}

private func hideUnityWindow() {
    if(UnityEmbeddedSwift.hostMainWindow == nil) {
        print("WARNING: hostMainWindow is nil! Cannot switch from Unity window to previous window")
    }
    else {
    UnityEmbeddedSwift.hostMainWindow?.makeKeyAndVisible()
    }
}

private func pauseUnityWindow() {
    ufw.pause(true)
}

private func unpauseUnityWindow() {
    ufw.pause(false)
}

private func unloadUnityWindow() {
    if unityIsInitialized() {
        UnityEmbeddedSwift.cachedMessages.removeAll()
        ufw.unloadApplication()
    }
}

private func sendUnityMessageToGameObject() {
    if (UnityEmbeddedSwift.cachedMessages.count >= 0 && unityIsInitialized())
    {
        for msg in UnityEmbeddedSwift.cachedMessages {
            ufw.sendMessageToGO(withName: msg.objectName, functionName: msg.methodName, message: msg.messageBody)
        }

        UnityEmbeddedSwift.cachedMessages.removeAll()
    }
}

private func UnityFrameworkLoad() -> UnityFramework? {
    let bundlePath: String = Bundle.main.bundlePath + "/Frameworks/UnityFramework.framework"

    let bundle = Bundle(path: bundlePath )
    if bundle?.isLoaded == false {
        bundle?.load()
    }

    let ufw = bundle?.principalClass?.getInstance()
    if ufw?.appController() == nil {
        // unity is not initialized
        //            ufw?.executeHeader = &mh_execute_header

        let machineHeader = UnsafeMutablePointer<MachHeader>.allocate(capacity: 1)
        machineHeader.pointee = _mh_execute_header

        ufw!.setExecuteHeader(machineHeader)
    }
    return ufw
}

}

But iam getting an error when iam trying to give the build
The error is ----->>No such module 'UnityFramework'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.