Skip to content

Commit

Permalink
Initial upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Rvthof authored Oct 7, 2021
0 parents commit 49aeaef
Show file tree
Hide file tree
Showing 11 changed files with 19,306 additions and 0 deletions.
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
The Apache License v2.0

Copyright 2021 Siemens

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## UnityWrapperWidget
[My widget description]

## Features
[feature highlights]

## Usage
[step by step instructions]

## Demo project
[link to sandbox]

## Issues, suggestions and feature requests
[link to GitHub issues]

## Development and contribution

1. Install NPM package dependencies by using: `npm install`. If you use NPM v7.x.x, which can be checked by executing `npm -v`, execute: `npm install --legacy-peer-deps`.
1. Run `npm start` to watch for code changes. On every change:
- the widget will be bundled;
- the bundle will be included in a `dist` folder in the root directory of the project;
- the bundle will be included in the `deployment` and `widgets` folder of the Mendix test project.

[specify contribution]
19,057 changes: 19,057 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "unitywrapperwidget",
"widgetName": "UnityWrapperWidget",
"version": "1.0.0",
"description": "My widget description",
"copyright": "2021 Siemens",
"author": "Rob Van 't Hof",
"engines": {
"node": ">=12"
},
"config": {
"projectPath": "C:/Mendix/UnityWidget-TestApp",
"mendixHost": "http://localhost:8080",
"developmentPort": "3000"
},
"packagePath": "siemens",
"scripts": {
"start": "pluggable-widgets-tools start:web",
"build": "pluggable-widgets-tools build:web",
"lint": "pluggable-widgets-tools lint",
"lint:fix": "pluggable-widgets-tools lint:fix",
"prerelease": "npm run lint",
"release": "pluggable-widgets-tools release:web"
},
"license": "Apache-2.0",
"devDependencies": {
"@mendix/pluggable-widgets-tools": "^9.0.0"
},
"dependencies": {
"classnames": "^2.2.6",
"react-hot-loader": "^4.13.0",
"react-unity-webgl": "^8.5.1"
}
}
5 changes: 5 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const base = require("@mendix/pluggable-widgets-tools/configs/prettier.base.json");

module.exports = {
...base
};
12 changes: 12 additions & 0 deletions src/UnityWrapperWidget.editorPreview.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component, createElement } from "react";
import { UnityWrapper } from "./components/UnityWrapper";

export class preview extends Component {
render() {
return <UnityWrapper />;
}
}

export function getPreviewCss() {
return require("./ui/UnityWrapperWidget.css");
}
22 changes: 22 additions & 0 deletions src/UnityWrapperWidget.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Component, createElement } from "react";
import Unity, { UnityContext } from "react-unity-webgl";

import { UnityWrapper } from "./components/UnityWrapper";
import "./ui/UnityWrapperWidget.css";


export const UnityWrapperWidget = ({ loaderUrl, dataUrl, frameworkUrl, codeUrl, width, height, fullscreenBtn, actions }) => {
if (loaderUrl.status != "loading") {
return <UnityWrapper
loaderUrl={loaderUrl.value}
dataUrl={dataUrl.value}
frameworkUrl={frameworkUrl.value}
codeUrl={codeUrl.value}
width={width}
height={height}
fullscreenBtn={fullscreenBtn}
actions={actions}
/>;
}
return null;
}
77 changes: 77 additions & 0 deletions src/UnityWrapperWidget.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<widget id="siemens.unitywrapperwidget.UnityWrapperWidget" pluginWidget="true" needsEntityContext="true" offlineCapable="true"
supportedPlatform="Web"
xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../node_modules/mendix/custom_widget.xsd">
<name>Unity Wrapper Widget</name>
<description>My widget description</description>
<icon/>
<properties>
<propertyGroup caption="General">
<property key="sampleText" type="string" required="false">
<caption>Default value</caption>
<description>Sample text input</description>
</property>
<property key="loaderUrl" type="attribute" required="true">
<caption>Loader URL</caption>
<description></description>
<attributeTypes>
<attributeType name="String" />
</attributeTypes>
</property>
<property key="dataUrl" type="attribute" required="true">
<caption>Data URL</caption>
<description></description>
<attributeTypes>
<attributeType name="String" />
</attributeTypes>
</property>
<property key="frameworkUrl" type="attribute" required="true">
<caption>Framework URL</caption>
<description></description>
<attributeTypes>
<attributeType name="String" />
</attributeTypes>
</property>
<property key="codeUrl" type="attribute" required="true">
<caption>Code URL</caption>
<description></description>
<attributeTypes>
<attributeType name="String" />
</attributeTypes>
</property>
</propertyGroup>
<propertyGroup caption="Interaction">
<property key="width" type="string">
<caption>Width</caption>
<description>Width of the player</description>
</property>
<property key="height" type="string">
<caption>Height</caption>
<description>Height of the player</description>
</property>
<property key="fullscreenBtn" type="boolean" defaultValue="true">
<caption>Show Fullscreen button</caption>
<description>Adds a fullscreen toggle button.</description>
</property>
</propertyGroup>
<propertyGroup caption="Actions">
<property key="actions" type="object" isList="true" required="false">
<caption>Actions</caption>
<description>A list of actions to interact with the Unity app.</description>
<properties>
<propertyGroup caption="Actions">
<property key="actionName" type="string" required="false">
<caption>Unity action name</caption>
<description/>
</property>
<property key="action" type="action" required="false">
<caption>Triggered action</caption>
<description/>
</property>
</propertyGroup>
</properties>
</property>
</propertyGroup>
</properties>
</widget>
43 changes: 43 additions & 0 deletions src/components/UnityWrapper.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Component, createElement } from "react";
import Unity, { UnityContext } from "react-unity-webgl";



export const UnityWrapper = ({ loaderUrl, dataUrl, frameworkUrl, codeUrl, width, height, fullscreenBtn, actions }) => {

const ctx = new UnityContext({
loaderUrl: loaderUrl,
dataUrl: dataUrl,
frameworkUrl: frameworkUrl,
codeUrl: codeUrl,
});

const unityNode = (<Unity
unityContext={ctx}
style={{
height: width || 300,
width: height || 150,
}}
/>);

for (let i = 0; i < actions.length; i++) {
const el = actions[i];
ctx.on(el.actionName, () => {
el.action.execute();
})
}

const onFullscreen = () => {
ctx.setFullscreen(true);
}

if (fullscreenBtn) {
return <div>{unityNode}
<div onClick={onFullscreen} className={"btn"}>
<span class="glyphicon glyphicon-fullscreen"></span>
</div>
</div>;
} else {
return <div>{unityNode}</div>;
}
}
11 changes: 11 additions & 0 deletions src/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="UnityWrapperWidget" version="1.0.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="UnityWrapperWidget.xml"/>
</widgetFiles>
<files>
<file path="siemens/unitywrapperwidget"/>
</files>
</clientModule>
</package>
6 changes: 6 additions & 0 deletions src/ui/UnityWrapperWidget.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
Place your custom CSS here
*/
.widget-hello-world {

}

0 comments on commit 49aeaef

Please sign in to comment.