推进度!
This commit is contained in:
2115
Assets/OtherPlugins/UI Spline Renderer/Example/Example Scene.unity
Normal file
2115
Assets/OtherPlugins/UI Spline Renderer/Example/Example Scene.unity
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4cb97132743ed84e8926b32c0e21b6a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fa77eec39f8ab541993402f8b658f8f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI_Spline_Renderer.Example
|
||||
{
|
||||
public class DragPortExample : MonoBehaviour
|
||||
{
|
||||
// This is a just marker script
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da33482d98404d569789131816357757
|
||||
timeCreated: 1690506079
|
||||
@@ -0,0 +1,72 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Splines;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI_Spline_Renderer.Example
|
||||
{
|
||||
public class DraggableSplinePointExample : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler
|
||||
{
|
||||
public UISplineRenderer uiSplineRenderer;
|
||||
public Image myImage;
|
||||
public int splineIndex;
|
||||
public int knotIndex;
|
||||
public Color connectedColor;
|
||||
public bool isConnected;
|
||||
BezierKnot _originalKnot;
|
||||
|
||||
/*
|
||||
* You must set false of the raycastTarget value of the UISplineRenderer and Image of this gameObject OnBeginDrag().
|
||||
* Because it can block the raycast going to a port that pointer hovered.
|
||||
*/
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
var pos = transform.parent.InverseTransformPoint(eventData.position);
|
||||
var knot = new BezierKnot(pos);
|
||||
uiSplineRenderer.splineContainer[splineIndex].SetKnot(knotIndex, knot);
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
uiSplineRenderer.raycastTarget = false;
|
||||
myImage.raycastTarget = false;
|
||||
|
||||
uiSplineRenderer.color = Color.white;
|
||||
if(!isConnected)_originalKnot = uiSplineRenderer.splineContainer[splineIndex][knotIndex];
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
foreach (var go in eventData.hovered)
|
||||
{
|
||||
if (go.GetComponent<DragPortExample>())
|
||||
{
|
||||
Connect(go.transform);
|
||||
uiSplineRenderer.raycastTarget = true;
|
||||
myImage.raycastTarget = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
void Connect(Transform t)
|
||||
{
|
||||
var pos = transform.parent.InverseTransformPoint(t.position);
|
||||
var knot = new BezierKnot(pos);
|
||||
uiSplineRenderer.splineContainer[splineIndex].SetKnot(knotIndex, knot);
|
||||
uiSplineRenderer.color = connectedColor;
|
||||
isConnected = true;
|
||||
}
|
||||
|
||||
void Disconnect()
|
||||
{
|
||||
uiSplineRenderer.color = Color.white;
|
||||
uiSplineRenderer.splineContainer[splineIndex].SetKnot(knotIndex, _originalKnot);
|
||||
isConnected = false;
|
||||
uiSplineRenderer.raycastTarget = true;
|
||||
myImage.raycastTarget = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01ab4fe8e6ee4cfd890ed9514bb2f188
|
||||
timeCreated: 1690505945
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UI_Spline_Renderer;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI_Spline_Renderer.Example
|
||||
{
|
||||
public class UISplineRendererExample : MonoBehaviour
|
||||
{
|
||||
public UISplineRenderer target_uvAnimation;
|
||||
public UISplineRenderer target_interaction;
|
||||
|
||||
void Start()
|
||||
{
|
||||
target_interaction.GetComponent<Button>().onClick.AddListener(() => Debug.Log($"Spline Clicked !"));
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
UpdateUV();
|
||||
}
|
||||
|
||||
void UpdateUV()
|
||||
{
|
||||
target_uvAnimation.uvOffset += new Vector2(0, Time.deltaTime * 2);
|
||||
target_uvAnimation.clipRange = new Vector2(0, (Mathf.Sin(Time.time) + 1) * 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc7f22c11927a054690bce364dda0652
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user