first commit
This commit is contained in:
35
Assets/Materials/JusticeScale/Demo/Scripts/ClickAndClone.cs
Normal file
35
Assets/Materials/JusticeScale/Demo/Scripts/ClickAndClone.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace JusticeScale.Demo.Scripts
|
||||
{
|
||||
[RequireComponent(typeof(Collider))]
|
||||
public class ClickAndClone : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject prefabToClone;
|
||||
[SerializeField] private float customMass;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
GetComponent<Collider>().isTrigger = true;
|
||||
}
|
||||
|
||||
private void OnMouseDown()
|
||||
{
|
||||
if (prefabToClone == null) return;
|
||||
|
||||
var clone = Instantiate(prefabToClone, transform.position, transform.rotation);
|
||||
|
||||
var dragScript = clone.GetComponent<DragAndDrop>();
|
||||
clone.GetComponent<Rigidbody>().mass = customMass;
|
||||
clone.transform.localScale = transform.lossyScale;
|
||||
clone.layer = gameObject.layer;
|
||||
|
||||
if (dragScript != null)
|
||||
{
|
||||
dragScript.isDragging = true;
|
||||
dragScript.StartDrag();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user