0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

neosでlogix その81

Posted at

概要

neosでlogixやってみる。
TouchToggleコンポーネントを使ってみる。

写真

image.png

TouchToggle

Name	Type	Description
persistent	Bool	Determines whether or not this item will be saved to the server.
UpdateOrder	Int	Controls the order in which this component is updated
Enabled	Bool	Controls whether or not this component is enabled
State	Bool	
EventType	TouchEventType	
ToggleEvent	EventState	
OnEvent	EventState	
OffEvent	EventState	
AcceptOutOfSightTouch	Bool	
AcceptPhysicalTouch	Bool	
AcceptRemoteTouch	Bool	
Vibrate	VibratePreset	
EditModeOnly	Bool	
ActiveUserFilter	ActiveUserHandling	
__legacyActiveUserRootOnly	Bool	

手順

  • devtooltipを装着。
  • 新規->3d->box
  • インスペクターを開き、コンポーネントを追加
  • Transform>Interaction>TouchToggle
  • logixtooltipを装着。
  • インターフェースを取り出す。

サンプルコード

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FrooxEngine
{
	[Category("Transform/Interaction")]
	public class TouchToggle : Component, ITouchable {
		public readonly Sync<bool> State;
		public readonly Sync<TouchEventType> EventType;
		public readonly Sync<EventState> ToggleEvent;
		public readonly Sync<EventState> OnEvent;
		public readonly Sync<EventState> OffEvent;
		public readonly Sync<bool> AcceptPhysicalTouch;
		public readonly Sync<bool> AcceptRemoteTouch;
		public readonly Sync<VibratePreset> Vibrate;
		protected override void OnAwake() {
			ToggleEvent.Value = EventState.Begin;
			EventType.Value = TouchEventType.Touch;
			AcceptPhysicalTouch.Value = true;
			AcceptRemoteTouch.Value = true;
			Vibrate.Value = VibratePreset.Short;
		}
		public void OnTouch(TouchEventInfo eventInfo) {
			switch(eventInfo.type)
			{
			case TouchType.Physical:
				if (!AcceptPhysicalTouch)
					return;
			break;
			case TouchType.Remote:
				if (!AcceptRemoteTouch)
					return;
			break;
			default:
				Debug.Warning("Unknown touch type: " + eventInfo.type);
				return;
			}
			bool prevState = State.Value;
			if (ToggleEvent.Value != EventState.None && eventInfo.GetEventState(EventType) == ToggleEvent.Value)
				State.Value = !State.Value;
			if (OnEvent.Value != EventState.None && eventInfo.GetEventState(EventType) == OnEvent.Value)
				State.Value = true;
			if (OffEvent.Value != EventState.None && eventInfo.GetEventState(EventType) == OffEvent.Value)
				State.Value = false;
			if (State.Value != prevState)
				eventInfo.source?.Slot.TryVibrate(Vibrate);
		}
	}
}





以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?