Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Getting error Assets/Drag_drop.cs(22,21): error CS0029: Cannot implicitly convert type `UnityEngine.GameObject' to `UnityEngine.Transform' please help

$
0
0
using System.Collections; using System.Collections.Generic; using UnityEngine.UI; using UnityEngine; using UnityEngine.EventSystems; public class Drag_drop : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler { public Transform parentToReturnTo = null; GameObject placeholder = null; public GameObject placeholderParent = null; public void OnBeginDrag(PointerEventData eventData){ Debug.Log ("OnBeginDrag"); placeholder = new GameObject(); placeholder.transform.SetParent(this.transform.parent); LayoutElement le = placeholder.AddComponent(); le.preferredWidth = this.GetComponent().preferredWidth; le.preferredHeight = this.GetComponent().preferredHeight; le.flexibleWidth = 0; le.flexibleHeight = 0; placeholder.transform.SetSiblingIndex(this.transform.GetSiblingIndex()); parentToReturnTo = this.transform.parent; placeholderParent = parentToReturnTo; this.transform.SetParent ( this.transform.parent.parent ); GetComponent().blocksRaycasts = false; } public void OnDrag(PointerEventData eventData){ //Debug.Log ("OnDrag"); this.transform.position = eventData.position; if(placeholder.transform.parent != placeholderParent){ placeholder.transform.SetParent(placeholderParent.transform); } int newSiblingindex = placeholderParent.transform.childCount; for(int i=0; i().blocksRaycasts = true; Destroy(placeholder); } } I am getting this error 1.Assets/Drag_drop.cs(22,21): error CS0029: Cannot implicitly convert type `UnityEngine.GameObject' to `UnityEngine.Transform' Please help me

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>