Bild wird bei der Instanziierung nicht angezeigtC#

Ein Treffpunkt für C#-Programmierer
Guest
 Bild wird bei der Instanziierung nicht angezeigt

Post by Guest »

Ich habe ein Skript in Unity, das eine Kopie eines Bildes in einem Level-Editor-System erstellt, das dort, wo sich die Maus befindet, eine durchsichtige Kopie erstellt. Aus irgendeinem Grund wird die durchsichtige Kopie nicht angezeigt, aber im Inspektor ist sie aktiviert und so weiter ist bis auf den Alphawert mit dem anderen Bild identisch. Der Code ist hier:

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

[System.Serializable]
public class SlotPrefab
{
public string slotName;
public GameObject slot;
public GameObject prefab;
}

public class Editor : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
public List slotPrefabList = new List();

public GameObject panel;

private bool isDragging = false;
private SlotPrefab hologramSlot = null;
private GameObject slotHologram = null;

void Update()
{
if (isDragging && slotHologram != null)
{
RectTransform rect = slotHologram.GetComponent();
rect.position = Input.mousePosition;
rect.position = new Vector3(rect.position.x, rect.position.y, 0f);
}
}

public void OnPointerDown(PointerEventData eventData)
{
foreach (SlotPrefab slot in slotPrefabList)
{
if (eventData.pointerCurrentRaycast.gameObject == slot.slot)
{
isDragging = true;
slotHologram = (GameObject) Instantiate(slot.slot);
slotHologram.name = "Hologram";
slotHologram.transform.SetParent(transform);
hologramSlot = slot;
SetHologramTransparency(slotHologram, 0.5f);
break;
}
}

}

public void OnPointerUp(PointerEventData eventData)
{
if (slotHologram != null)
{
isDragging = false;

RectTransform panelRect = panel.GetComponent();
RectTransform hologramRect = slotHologram.GetComponent();

float panelRightEdge = panelRect.position.x + panelRect.rect.width / 2f;
float hologramLeftEdge = hologramRect.position.x - hologramRect.rect.width / 2f;

if (hologramLeftEdge

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post