public void copyToText(Text target) { GameObject gameObject = new GameObject(); Text t = gameObject.AddComponent <Text>(); t.alignByGeometry = alignByGeometry; t.alignment = alignment; t.font = UnityEditor.AssetDatabase.LoadAssetAtPath <Font>(fontPath); if (t.font == null) { Debug.Log("Font not found"); //set default font //UnityEditor.AssetDatabase.LoadAssetAtPath<Font>(GameManager.defaultFontPath); //Might not need since prefab will have default font } t.fontSize = fontSize; t.fontStyle = fontStyle; t.lineSpacing = lineSpacing; t.resizeTextForBestFit = resizeTextForBestFit; t.resizeTextMaxSize = resizeTextMaxSize; t.resizeTextMinSize = resizeTextMinSize; t.supportRichText = supportRichText; t.text = text; XMLSerializationManager.copyComponent(t, target); GameObject.Destroy(gameObject); }
public void copyToScrollbar(Scrollbar target) { GameObject gameObject = new GameObject(); Scrollbar sb = gameObject.AddComponent <Scrollbar>(); sb.direction = direction; //sb.handleRect = handleRect.toRectTransform(null); //Needs to get the rect transform of the Handle after its instantiated sb.numberOfSteps = numberOfSteps; sb.onValueChanged = onValueChanged; sb.size = size; sb.value = value; XMLSerializationManager.copyComponent(sb, target); GameObject.Destroy(gameObject); }
//Creates a rect transform using the fields in this RectTransformData and applies it to a parent. While not necessary to specify a parent this //is to keep a consistent style with the other components, since Unity gui elements need a parent to initialize public void copyToRectTransform(RectTransform target) { GameObject gameObject = new GameObject(); RectTransform rc = gameObject.AddComponent <RectTransform>(); rc.anchoredPosition = anchoredPosition; rc.anchorMax = anchorMax; rc.anchorMin = anchorMin; rc.offsetMax = offsetMax; rc.offsetMin = offsetMin; rc.pivot = pivot; rc.sizeDelta = sizeDelta; XMLSerializationManager.copyComponent(rc, target); GameObject.Destroy(gameObject); }
public void copyToRawImage(RawImage target) { GameObject gameObject = new GameObject(); RawImage image = gameObject.AddComponent <RawImage>(); image.texture = (Texture)UnityEditor.AssetDatabase.LoadAssetAtPath(sourceImagePath, typeof(Texture)); if (image.texture == null) { Debug.Log("Image file not found at: " + sourceImagePath); //set a default picture in its place } image.uvRect = uvRect; XMLSerializationManager.copyComponent(image, target); GameObject.Destroy(gameObject); }
public void copyToScrollRect(ScrollRect target) //Scroll rect stuff is all kinds of screwed because it needs references to the other gameobjects { GameObject gameObject = new GameObject(); ScrollRect rect = gameObject.AddComponent <ScrollRect>(); //rect.normalizedPosition = normalizedPosition; rect.decelerationRate = decelerationRate; rect.elasticity = elasticity; rect.inertia = inertia; rect.movementType = movementType; rect.horizontal = false; rect.scrollSensitivity = scrollSensitivity; rect.velocity = velocity; rect.vertical = vertical; // rect.verticalNormalizedPosition = verticalNormalizedPosition; rect.verticalScrollbarSpacing = verticalScrollbarSpacing; rect.verticalScrollbarVisibility = verticalScrollbarVisibility; XMLSerializationManager.copyComponent(rect, target); GameObject.Destroy(gameObject); }
public void copyToImage(Image target) { GameObject gameObject = new GameObject(); Image image = gameObject.AddComponent <Image>(); image.sprite = (Sprite)UnityEditor.AssetDatabase.LoadAssetAtPath(sourceImagePath, typeof(Sprite)); if (image.sprite == null) { Debug.LogWarning("Image file not found at: " + sourceImagePath); //set a default picture in its place } image.alphaHitTestMinimumThreshold = alphaHitTestMinimumThreshold; image.fillAmount = fillAmount; image.fillCenter = fillCenter; image.fillClockwise = fillClockwise; image.fillMethod = fillMethod; image.fillOrigin = fillOrigin; image.preserveAspect = preserveAspect; image.type = type; image.color = color; XMLSerializationManager.copyComponent(image, target); GameObject.Destroy(gameObject); }