-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 49aeaef
Showing
11 changed files
with
19,306 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
Place your custom CSS here | ||
*/ | ||
.widget-hello-world { | ||
|
||
} |