Initial commit

This commit is contained in:
HussienX72u
2026-07-21 08:56:10 +03:00
commit 4017028111
9410 changed files with 2150500 additions and 0 deletions
@@ -0,0 +1,62 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using NaughtyAttributes;
using UnityEngine;
using UnityEngine.Events;
public class BaseInteractable : MonoBehaviour, IInteractable
{
public UnityEvent onSelectEnterEvent;
public UnityEvent onSelectExitEvent;
public UnityEvent onHoverEnterEvent;
public UnityEvent onHoverExitEvent;
public virtual void onHoverEnter()
{
onHoverEnterEvent?.Invoke();
}
public virtual void onHoverExit()
{
onHoverExitEvent?.Invoke();
}
private void OnMouseEnter()
{
onHoverEnter();
}
private void OnMouseExit()
{
onHoverExit();
}
public virtual void onSelectEnter()
{
onSelectEnterEvent?.Invoke();
}
public virtual void onSelectExit()
{
onSelectExitEvent?.Invoke();
}
public virtual void highLightOn()
{
Outline outline = GetComponent<Outline>();
if (outline == null)
{
outline = gameObject.AddComponent<Outline>();
outline.OutlineMode = Outline.Mode.OutlineVisible;
outline.OutlineWidth = 7f;
}
}
public virtual void highLightOff()
{
if (TryGetComponent<Outline>(out Outline outline))
{
Destroy(outline);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ac30058eb2a831244b1e538478741ad8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
using UnityEngine;
/// <summary>
/// Data/configuration component placed on block prefabs.
/// Stores per-prefab drag settings so GhostManager can read them at instantiation time.
/// All drag, snap, and placement logic has moved to GhostManager.
/// </summary>
public class GrabInteractable : MonoBehaviour
{
[Header("Attachment")]
[SerializeField] private Transform attachPoint;
[Header("Surface Alignment")]
public bool alignToSurfaceNormal = true;
public float alignmentSpeed = 15f;
public bool snapRotation = false;
[Header("Movement")]
public float followSpeed = 20f;
public float heightOffset = 0f;
[Header("Validation & Visuals")]
[SerializeField] private IValidator validator;
public Color validTint = new Color(0.5f, 1.0f, 0.5f, 1.0f);
public Color invalidTint = new Color(1.0f, 0.5f, 0.5f, 1.0f);
/// <summary>Returns the designated attach/pivot point, or this transform if none is set.</summary>
public Transform GetAttachPoint() => attachPoint;
/// <summary>Returns the PlacementValidator – checks the component on this GameObject as fallback.</summary>
public IValidator GetValidator() => validator != null ? validator : GetComponent<IValidator>();
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d9a466110b129074db957157c7ec5b2f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class HoveredUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
private GhostManagerV2 ghostManager;
private void Start()
{
ghostManager = GhostManagerV2.getInstance();
}
public void OnPointerEnter(PointerEventData eventData)
{
ghostManager.clearGhost();
ghostManager.setDrag(false);
if (!InputModeManager.Is(InputMode.UI))
InputModeManager.Push(InputMode.UI);
}
public void OnPointerExit(PointerEventData eventData)
{
ghostManager.setupBlock();
ghostManager.setDrag(true);
InputModeManager.Pop(InputMode.UI);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 569c8fbf5be661b47a7b04e2bd8e64f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
using UnityEngine;
public interface IInteractable
{
Transform transform { get; }
void onSelectEnter();
void onSelectExit();
void onHoverEnter();
void onHoverExit();
void highLightOn();
void highLightOff();
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2d21c93488c34fe4bb7546d994981d58
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,65 @@
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UnityEngine.UIElements;
public class UIInteractable : BaseInteractable, IPointerDownHandler
{
private UIManager uIManager;
[SerializeField] private BlockData blockData;
// private Button uIButton;
private bool isSelected = false;
private Color originalColor;
private void Start()
{
uIManager = UIManager.getInstance();
// uIButton = GetComponent<Button>();
// originalColor = uIButton.image.color;
// Set icon from BlockData if available
// if (blockData != null && blockData.icon != null)
// {
// uIButton.image.sprite = Sprite.Create(
// blockData.icon,
// new Rect(0, 0, blockData.icon.width, blockData.icon.height),
// new Vector2(0.5f, 0.5f));
// }
// if (uIButton != null)
// uIButton.onClick.AddListener(onSelectEnter);
}
public override void onSelectEnter()
{
if (!isSelected)
{
isSelected = true;
uIManager.selectUIInteractable(this);
// uIButton.image.color = Color.green;
}
base.onSelectEnter();
}
public override void onSelectExit()
{
isSelected = false;
// uIButton.image.color = originalColor;
base.onSelectExit();
}
internal BlockData getAssociatedBlockData() => blockData;
public void setBlockData(BlockData blockData)
{
this.blockData = blockData;
}
// public Button getButton() => uIButton;
public void OnPointerDown(PointerEventData eventData)
{
onSelectEnter();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6bc96f60788466141a4a58584aa21a0b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: