This repository has been archived by the owner on Jan 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
One-to-one GameObject converter (#1472)
- Loading branch information
Jamie Brynes
authored
Sep 1, 2020
1 parent
dbf6c0d
commit 9d1ea5e
Showing
6 changed files
with
78 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
3 changes: 3 additions & 0 deletions
3
workers/unity/Packages/io.improbable.gdk.core/Editor/SceneAuthoring.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...nity/Packages/io.improbable.gdk.core/Editor/SceneAuthoring/ConvertToSingleEntityEditor.cs
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,36 @@ | ||
using Improbable.Gdk.Core.SceneAuthoring; | ||
using UnityEditor; | ||
|
||
namespace Improbable.Gdk.Core.Editor.SceneAuthoring | ||
{ | ||
[CustomEditor(typeof(ConvertToSingleEntity))] | ||
public class ConvertToSingleEntityEditor : UnityEditor.Editor | ||
{ | ||
private SerializedProperty useSpecificEntityIdProperty; | ||
private SerializedProperty desiredEntityIdProperty; | ||
private SerializedProperty readAclProperty; | ||
|
||
private void OnEnable() | ||
{ | ||
useSpecificEntityIdProperty = serializedObject.FindProperty(nameof(ConvertToSingleEntity.UseSpecificEntityId)); | ||
desiredEntityIdProperty = serializedObject.FindProperty(nameof(ConvertToSingleEntity.DesiredEntityId)); | ||
readAclProperty = serializedObject.FindProperty(nameof(ConvertToSingleEntity.ReadAcl)); | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
serializedObject.Update(); | ||
|
||
EditorGUILayout.PropertyField(useSpecificEntityIdProperty); | ||
|
||
if (useSpecificEntityIdProperty.boolValue) | ||
{ | ||
EditorGUILayout.PropertyField(desiredEntityIdProperty); | ||
} | ||
|
||
EditorGUILayout.PropertyField(readAclProperty); | ||
|
||
serializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...Packages/io.improbable.gdk.core/Editor/SceneAuthoring/ConvertToSingleEntityEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
workers/unity/Packages/io.improbable.gdk.core/SceneAuthoring/ConvertToSingleEntity.cs
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,32 @@ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace Improbable.Gdk.Core.SceneAuthoring | ||
{ | ||
[AddComponentMenu("SpatialOS/Authoring Components/Convert to Single Entity")] | ||
public class ConvertToSingleEntity : MonoBehaviour, IConvertGameObjectToSpatialOsEntity | ||
{ | ||
[SerializeField] internal bool UseSpecificEntityId; | ||
[SerializeField] internal long DesiredEntityId; | ||
[SerializeField] internal string[] ReadAcl = { }; | ||
|
||
public List<ConvertedEntity> Convert() | ||
{ | ||
var components = GetComponents<ISpatialOsAuthoringComponent>(); | ||
var template = new EntityTemplate(); | ||
|
||
foreach (var component in components) | ||
{ | ||
component.WriteTo(template); | ||
} | ||
|
||
template.SetReadAccess(ReadAcl); | ||
|
||
var entity = UseSpecificEntityId | ||
? new ConvertedEntity(new EntityId(DesiredEntityId), template) | ||
: new ConvertedEntity(template); | ||
|
||
return new List<ConvertedEntity> { entity }; | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
workers/unity/Packages/io.improbable.gdk.core/SceneAuthoring/ConvertToSingleEntity.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.