-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from Nytra/main
Allow ComponentsDataFeed to enumerate the component library, add ButtonAttachComponent, cleanup stuff
- Loading branch information
Showing
7 changed files
with
304 additions
and
64 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
ProjectObsidian/Components/Common UI/Button Interactions/ButtonAttachComponent.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,43 @@ | ||
using System; | ||
using FrooxEngine; | ||
using FrooxEngine.Undo; | ||
|
||
namespace Obsidian; | ||
|
||
[Category(new string[] { "Obsidian/Common UI/Button Interactions" })] | ||
public class ButtonAttachComponent : Component, IButtonPressReceiver, IComponent, IComponentBase, IDestroyable, IWorker, IWorldElement, IUpdatable, IChangeable, IAudioUpdatable, IInitializable, ILinkable | ||
{ | ||
public readonly SyncRef<Slot> TargetSlot; | ||
|
||
public readonly SyncType ComponentType; | ||
|
||
public readonly Sync<bool> Undoable; | ||
|
||
protected override void OnAttach() | ||
{ | ||
base.OnAwake(); | ||
Undoable.Value = true; | ||
} | ||
|
||
public void Pressed(IButton button, ButtonEventData eventData) | ||
{ | ||
Slot target = TargetSlot.Target; | ||
Type componentType = ComponentType.Value; | ||
if (target != null && componentType != null && componentType.ContainsGenericParameters == false) | ||
{ | ||
var comp = target.AttachComponent(componentType); | ||
if (Undoable) | ||
{ | ||
comp.CreateSpawnUndoPoint(); | ||
} | ||
} | ||
} | ||
|
||
public void Pressing(IButton button, ButtonEventData eventData) | ||
{ | ||
} | ||
|
||
public void Released(IButton button, ButtonEventData eventData) | ||
{ | ||
} | ||
} |
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
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
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
Oops, something went wrong.