public override void ToolModeSwap() { if (Input.GetKeyDown(KeyCode.Tab)) { spriteMode = ScenePrimer.curEditorPrimer.curSpriteMode = !ScenePrimer.curEditorPrimer.curSpriteMode; } curTileSelector.gameObject.SetActive(!spriteMode); if (ScenePrimer.curEditorPrimer.curSpriteMode) { if (ScenePrimer.curEditorPrimer.curSpriteId != -1) { Icon = EditorPrimer.spriteIconRenderer; Icon.sprite = XCPManager.PngToSprite(XCPManager.currentXCP.spriteTextures[ScenePrimer.curEditorPrimer.curSpriteId]); } } Icon.gameObject.SetActive(spriteMode); if (spriteMode) { ScenePrimer.curEditorPrimer.UpdateLayer(3); } else { ScenePrimer.curEditorPrimer.UpdateLayer(0); } }
public void UpdateTexturePrew() { if (texturePrew && editorCreated) { UpdateLayer(-1); if (curSpriteMode) { if (spriteId != -1) { texturePrew.sprite = XCPManager.PngToSprite(XCPManager.currentXCP.spriteTextures[spriteId]); } } else { if (curTileId != -1) { if (XCPManager.currentXCP.tileTextures != null) { texturePrew.sprite = XCPManager.PngToSprite(XCPManager.currentXCP.tileTextures[curTile]); } } } } GlobalToolManager.SendToolUpdate(); }
public void GenerateMapView() { if (XCPManager.currentXCP.entities != null) { if (newField != null) { if (XCPManager.currentXCP != null) { newField.hNr = 3; if (XCPManager.currentXCP.xpcMaps != null) { newField.items = new FieldItem[XCPManager.currentXCP.entities.Length]; for (int i = 0; i < newField.items.Length; i++) { newField.items[i].index = i; if (XCPManager.currentXCP.entities[i].entSprites.Length != 0) { newField.items[i].useIcon = true; newField.items[i].itemIcon = XCPManager.PngToSprite(XCPManager.currentXCP.entities[i].entSprites[0]); } newField.items[i].selectable = true; newField.items[i].itemPressMethod = ItemHandler; newField.items[i].itemRightPressMethod = CreateSpriteEditor; } newField.GenerateViewItems(); } } } } }
// Generate the sprites that are placed on the cunk. this must only happen once in a chunks life time. // TODO : Move the generation to a separate class to improve system workflow, and extensibility. public void GenerateSprites() { if (curCunk.sprites != null) { if (curCunk.sprites.Length != 0) { // If the programer is not complying with the above instructions, then force a re-geneation of all sprites on the chunk. // This may be only good in editing mode. if (spriteContainer != null) { GameObject.Destroy(spriteContainer); spriteContainer = new GameObject("Sprites"); spriteContainer.transform.SetParent(transform); spriteContainer.transform.position = transform.position; } else { spriteContainer = new GameObject("Sprites"); spriteContainer.transform.SetParent(transform); spriteContainer.transform.position = transform.position; } GameObject spriteObj; SpriteRenderer spriteRender; MaterialPropertyBlock spriteProps; spriteProps = new MaterialPropertyBlock(); for (int i = 0; i < curCunk.sprites.Length; i++) { spriteObj = new GameObject(curCunk.sprites[i].spriteId.ToString()); spriteObj.isStatic = true; spriteObj.transform.SetParent(spriteContainer.transform); spriteObj.transform.localPosition = new Vector3(curCunk.sprites[i].posx, 0.2f, curCunk.sprites[i].posy); spriteRender = spriteObj.AddComponent <SpriteRenderer>(); spriteRender.material = ScenePrimer.StandardSprite; spriteRender.GetPropertyBlock(spriteProps); spriteRender.transform.eulerAngles = new Vector2(90, 0); spriteRender.sprite = XCPManager.PngToSprite(XCPManager.currentXCP.spriteTextures[curCunk.sprites[i].spriteId]); spriteProps.SetTexture("_tex", spriteRender.sprite.texture); spriteProps.SetColor("_col", MapDataConverter.ColToColor32(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].forColor)); spriteRender.SetPropertyBlock(spriteProps); if (ScenePrimer.curEditorPrimer != null) { spriteObj.AddComponent <BoxCollider>().isTrigger = true; spriteObj.AddComponent <SpriteInfo>().spriteIndex = i; } if (XCPManager.currentXCP.spriteTextures[curCunk.sprites[i].spriteId].colliders != null) { for (int col = 0; i < XCPManager.currentXCP.spriteTextures[curCunk.sprites[i].spriteId].colliders.Length; i++) { BoxCollider colider = spriteRender.gameObject.AddComponent <BoxCollider>(); } } spriteRender.sortingLayerName = EditorPrimer.GoodIdToBadUnityId(curCunk.sprites[i].sortLayer + 1); spriteRender.sortingOrder = SessionManager.SpriteSortByPos(spriteRender); } } } }
public void LoadXCP(string[] file) { XCPManager.XCPImportFromFile(file[0]); if (XCPManager.currentXCP != null) { curXPCName.text = XCPManager.currentXCP.xcpGameName; curXPCAuthor.text = XCPManager.currentXCP.xcpAuthor; curXPCDescript.text = XCPManager.currentXCP.xcpDescription; curXPCVer.text = "V." + XCPManager.currentXCP.xcpFormVersion.ToString(); iconPrew.sprite = XCPManager.PngToSprite(XCPManager.currentXCP.xcpIcon); newBtn.gameObject.SetActive(true); newField.items = null; GenerateMapView(); } }
public override void ToolUpdate() { if (ScenePrimer.curEditorPrimer.curSpriteMode) { if (ScenePrimer.curEditorPrimer.curSpriteId != -1) { spriteMode = true; curTileSelector.gameObject.SetActive(false); Icon.gameObject.SetActive(true); Icon = EditorPrimer.spriteIconRenderer; Icon.GetPropertyBlock(spriteProps); Icon.sprite = XCPManager.PngToSprite(XCPManager.currentXCP.spriteTextures[ScenePrimer.curEditorPrimer.curSpriteId]); spriteProps.SetColor("_col", MapDataConverter.ColToColor32(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].forColor)); spriteProps.SetTexture("_tex", Icon.sprite.texture); Icon.SetPropertyBlock(spriteProps); Icon.sortingLayerName = EditorPrimer.GoodIdToBadUnityId(ScenePrimer.curEditorPrimer.curSortingLayer + 1); } } }
public void GenerateMapView() { if (XCPManager.currentXCP.tileTextures != null) { if (ScenePrimer.curEditorPrimer.curTileId == -1) { ScenePrimer.curEditorPrimer.curTileId = 0; } if (newField != null) { if (XCPManager.currentXCP != null) { newField.hNr = 3; newField.useNumberShortCut = true; if (XCPManager.currentXCP.xpcMaps != null) { newField.items = new FieldItem[XCPManager.currentXCP.tileTextures.Length]; for (int i = 0; i < newField.items.Length; i++) { if (ScenePrimer.curEditorPrimer.curTileId == i) { newField.items[i].startSelect = true; } newField.items[i].index = i; newField.items[i].useIcon = true; newField.items[i].selectable = true; newField.items[i].itemIcon = XCPManager.PngToSprite(XCPManager.currentXCP.tileTextures[i]); newField.items[i].itemPressMethod = ItemHandler; //newField.items[i].itemDisplayText = "item"; } newField.GenerateViewItems(); } } } } }
public void GenerateMapView() { if (XCPManager.currentXCP.itemTextures != null) { if (ScenePrimer.curEditorPrimer.curSpriteId == -1) { ScenePrimer.curEditorPrimer.curSpriteId = 0; } if (newField != null) { if (XCPManager.currentXCP != null) { newField.hNr = 3; if (XCPManager.currentXCP.xpcMaps != null) { newField.items = new FieldItem[XCPManager.currentXCP.itemTextures.Length]; for (int i = 0; i < newField.items.Length; i++) { if (ScenePrimer.curEditorPrimer.curSpriteId == i) { newField.items[i].startSelect = true; } newField.items[i].index = i; newField.items[i].useIcon = true; newField.items[i].selectable = true; newField.items[i].itemIcon = XCPManager.PngToSprite(XCPManager.currentXCP.itemTextures[i]); newField.items[i].itemPressMethod = ItemHandler; newField.items[i].itemRightPressMethod = CreateSpriteEditor; } newField.GenerateViewItems(); } } } } }
public override void ToolPrimaryUse() { if (spriteMode) { usesDrag = false; targetChunk = SessionManager.GetChunk(Icon.transform.position, SessionManager.GetChunkCluster(Icon.transform.position), false); if (targetChunk != null) { Icon.transform.position = SessionManager.ObjPosition(Icon.transform.position); if (targetChunk.sprites == null) { targetChunk.sprites = new Spr[1]; targetChunk.sprites[0].posx = Icon.transform.position.x; targetChunk.sprites[0].posy = Icon.transform.position.z; targetChunk.sprites[0].sortLayer = (ushort)ScenePrimer.curEditorPrimer.curSortingLayer; targetChunk.sprites[0].spriteId = (ushort)ScenePrimer.curEditorPrimer.curSpriteId; } else { Array.Resize(ref targetChunk.sprites, targetChunk.sprites.Length + 1); targetChunk.sprites[targetChunk.sprites.Length - 1] = new Spr(); targetChunk.sprites[targetChunk.sprites.Length - 1].posx = Icon.transform.position.x; targetChunk.sprites[targetChunk.sprites.Length - 1].posy = Icon.transform.position.z; targetChunk.sprites[targetChunk.sprites.Length - 1].sortLayer = (ushort)ScenePrimer.curEditorPrimer.curSortingLayer; targetChunk.sprites[targetChunk.sprites.Length - 1].spriteId = (ushort)ScenePrimer.curEditorPrimer.curSpriteId; targetChunk.sprites[targetChunk.sprites.Length - 1].sortLayer = (ushort)ScenePrimer.curEditorPrimer.curSortingLayer; } if (targetChunk != null) { if (targetChunk.meshObjRef == null) { targetChunk.meshObjRef = targetChunk.chunkObjRef.GetComponent <TileMesh2D>(); } } targetChunk.meshObjRef.curCunk = targetChunk; if (targetChunk.meshObjRef.spriteContainer != null) { GameObject spriteObj = new GameObject(ScenePrimer.curEditorPrimer.curSpriteId.ToString()); spriteObj.transform.SetParent(targetChunk.meshObjRef.spriteContainer.transform); spriteObj.transform.localPosition = Icon.transform.position; if (targetChunk.sprites.Length == 1) { spriteObj.AddComponent <SpriteInfo>().spriteIndex = 0; } else { spriteObj.AddComponent <SpriteInfo>().spriteIndex = targetChunk.sprites.Length - 1; } SpriteRenderer spriteRender = spriteObj.AddComponent <SpriteRenderer>(); spriteRender.material = ScenePrimer.curEditorPrimer.worldMaterial; spriteRender.transform.eulerAngles = new Vector2(90, 0); spriteRender.sprite = XCPManager.PngToSprite(XCPManager.currentXCP.spriteTextures[ScenePrimer.curEditorPrimer.curSpriteId]); spriteRender.sortingOrder = SessionManager.SpriteSortByPos(spriteRender); spriteRender.sortingLayerName = EditorPrimer.GoodIdToBadUnityId(ScenePrimer.curEditorPrimer.curSortingLayer + 1); spriteObj.AddComponent <BoxCollider>().isTrigger = true; spriteRender.GetPropertyBlock(spriteProps); spriteRender.sprite = XCPManager.PngToSprite(XCPManager.currentXCP.spriteTextures[ScenePrimer.curEditorPrimer.curSpriteId]); spriteProps.SetColor("_col", MapDataConverter.ColToColor32(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].forColor)); spriteProps.SetTexture("_tex", spriteRender.sprite.texture); spriteRender.SetPropertyBlock(spriteProps); } else { targetChunk.meshObjRef.GenerateSprites(); } } } else { usesDrag = true; cursorTransform = CameraManager.curCamera.ScreenToWorldPoint(Input.mousePosition); cursorTransform.x = (float)System.Math.Round(cursorTransform.x / tileSize) * tileSize - tileSize * 0.5f; cursorTransform.z = (float)System.Math.Round(cursorTransform.z / tileSize) * tileSize + tileSize * 0.5f; SessionManager.PlaceTile(cursorTransform, ScenePrimer.curEditorPrimer.curLayer, ScenePrimer.curEditorPrimer.curTileId, true, false); } }
public override void WindowCreate(int sizeX, int sizeY, GameObject windowRef) { targetWindowRef = windowRef; // A realy bad way to overide. sizeX = 520; sizeY = 400; // Create a window shadow. windowShadow.uiObjName = "Shadow"; windowShadow.uiTextureRef = Resources.Load <Sprite>("BerrySystem/UI/shadow"); windowShadow.uiColor = new Color32(255, 255, 255, 255); windowShadow.uiSize = new Vector2(sizeX + 90, sizeY + 90); UiManager.CreateBackgroundObj(windowRef, windowShadow); // Create the window panel. windowPanel.uiSize = new Vector2(sizeX, sizeY); windowPanel.uiRayCast = true; UiManager.CreateBackgroundObj(windowRef, windowPanel).transform.parent.gameObject.AddComponent <QuickUiAnimator>().PlayFadeAnim(0, 1, false, false, 9f); UiTextObject windowTitle = new UiTextObject(); windowTitle.uiTextColor = new Color(0, 0, 0, 255); windowTitle.uiText = WindowGrabName(); windowTitle.uiSize = new Vector2(100, 19); windowTitle.uiTextAlign = TextAnchor.UpperCenter; windowTitle.uiPosition = new Vector2(0, 180); UiManager.CreateTextObj(windowRef, windowTitle); UiButtonObject saveButton = new UiButtonObject(); saveButton.uiPosition = new Vector2(210, -165); saveButton.uiSize = new Vector2(70, 34); saveButton.uiButtonBackgroundObject.uiRayCast = true; saveButton.uiButtonBackgroundObject.uiSize = saveButton.uiSize; saveButton.uiButtonBackgroundObject.uiColor = new Color32(100, 100, 100, 100); saveButton.uiButtonBackgroundObject.normalColor = new Color32(170, 170, 170, 100); saveButton.uiButtonBackgroundObject.hoverColor = new Color32(134, 166, 255, 100); saveButton.uiButtonBackgroundObject.pressedColor = new Color32(0, 150, 255, 100); saveButton.uiButtonIcon.uiColor = new Color32(255, 255, 255, 110); saveButton.uiButtonIcon.uiSize = new Vector2(saveButton.uiSize.x - 2, saveButton.uiSize.y - 2); saveButton.uiButtonText = new UiTextObject(); saveButton.uiButtonText.uiTextColor = new Color32(0, 0, 0, 255); saveButton.uiButtonText.uiTextAlign = TextAnchor.MiddleCenter; saveButton.uiButtonText.uiText = "Open"; openBtn = UiManager.CreateButton(windowRef, saveButton).GetComponent <UiIntractable>(); openBtn.gameObject.SetActive(false); openBtn.onMouseClickEvent = OpenMap; saveButton.uiButtonText.uiText = "New Map"; saveButton.uiSize = new Vector2(100, 34); saveButton.uiPosition = new Vector2(130, -165); newBtn = UiManager.CreateButton(windowRef, saveButton).GetComponent <UiIntractable>(); newBtn.onMouseClickEvent = NewMap; if (XCPManager.currentXCP == null) { newBtn.gameObject.SetActive(false); } UiBackgroundObject xpcInfoPanel = new UiBackgroundObject(); xpcInfoPanel.uiPosition = new Vector2(-108.07f, -15.12f); xpcInfoPanel.uiSize = new Vector2(284.07f, 340.45f); xpcInfoPanel.uiColor = new Color(0.9f, 0.9f, 0.9f, 1); UiManager.CreateBackgroundObj(windowRef, xpcInfoPanel); saveButton.uiButtonText.uiText = "Load"; saveButton.uiPosition = new Vector2(-8, -162); UiManager.CreateButton(windowRef, saveButton).gameObject.AddComponent <DropDownButton>().ACClick = XCPLoad; saveButton.uiButtonText.uiText = "Create"; saveButton.uiPosition = new Vector2(-85, -162); DropDownOption xcpCreate = new DropDownOption(); // Move over to the new way of doing things.... xcpCreate.targetNewWindow = new BXCPCreate(); xcpCreate.destroy = true; UiManager.CreateButton(windowRef, saveButton).gameObject.AddComponent <DropDownButton>().optionData = xcpCreate; if (ScenePrimer.curEditorPrimer.editorCreated) { saveButton.uiButtonText.uiText = "Save"; saveButton.uiPosition = new Vector2(-205, -162); xcpCreate.destroy = true; UiManager.CreateButton(windowRef, saveButton).gameObject.AddComponent <DropDownButton>().ACClick = SaveXCP; } UiBackgroundObject icon = new UiBackgroundObject(); icon.uiSize = new Vector2(92, 92); icon.uiPosition = new Vector2(-197.8f, 101.7f); icon.uiColor = new Color32(243, 243, 243, 255); iconPrew = UiManager.CreateBackgroundObj(windowRef, icon).GetComponent <Image>(); UiTextObject xcpTitle = new UiTextObject(); if (XCPManager.currentXCP == null) { xcpTitle.uiText = "NO XCP LOADED !"; } else { xcpTitle.uiText = XCPManager.currentXCP.xcpGameName; } xcpTitle.uiTextSize = 15; xcpTitle.uiTextColor = new Color(0, 0, 0, 1); xcpTitle.uiPosition = new Vector2(-59.55f, 127.11f); xcpTitle.uiSize = new Vector2(170.72f, 34); curXPCName = UiManager.CreateTextObj(windowRef, xcpTitle).GetComponent <Text>(); xcpTitle.uiText = ""; xcpTitle.uiTextSize = 13; xcpTitle.uiPosition = new Vector2(-59.55f, 104.4f); curXPCAuthor = UiManager.CreateTextObj(windowRef, xcpTitle).GetComponent <Text>(); xcpTitle.uiPosition = new Vector2(-157.5f, -126.8f); curXPCVer = UiManager.CreateTextObj(windowRef, xcpTitle).GetComponent <Text>(); xcpTitle.uiSize = new Vector2(269, 34); xcpTitle.uiPosition = new Vector2(-110, 28); curXPCDescript = UiManager.CreateTextObj(windowRef, xcpTitle).GetComponent <Text>(); if (XCPManager.currentXCP != null) { curXPCName.text = XCPManager.currentXCP.xcpGameName; curXPCAuthor.text = XCPManager.currentXCP.xcpAuthor; curXPCDescript.text = XCPManager.currentXCP.xcpDescription; curXPCVer.text = "V." + XCPManager.currentXCP.xcpFormVersion.ToString(); iconPrew.sprite = XCPManager.PngToSprite(XCPManager.currentXCP.xcpIcon); } UiItemFeild uiFileBrowser = new UiItemFeild(); uiFileBrowser.uiPosition = new Vector2(146.78f, 9.19f); uiFileBrowser.uiSize = new Vector2(209.7f, 291.82f); uiFileBrowser.uiColor = new Color32(239, 239, 239, 255); newField = UiManager.CreateItemsFeild(windowRef, uiFileBrowser); xcpTitle.uiPosition = new Vector2(200f, 127.11f); xcpTitle.uiSize = new Vector2(170.72f, 34); xcpTitle.uiText = "No maps!"; noMaps = UiManager.CreateTextObj(windowRef, xcpTitle).GetComponent <Text>(); GenerateMapView(); // windowRef.AddComponent <QuickUiAnimator>().PlayPosAnim(new Vector2(0, 20), new Vector2(0, 0), false, false, 120f); }
public override void WindowCreate(int sizeX, int sizeY, GameObject windowRef) { targetWindowRef = windowRef; // A realy bad way to overide. sizeX = 520; sizeY = 400; // Create a window shadow. windowShadow.uiObjName = "Shadow"; windowShadow.uiTextureRef = Resources.Load <Sprite>("BerrySystem/UI/shadow"); windowShadow.uiColor = new Color32(255, 255, 255, 255); windowShadow.uiSize = new Vector2(sizeX + 90, sizeY + 90); UiManager.CreateBackgroundObj(windowRef, windowShadow); // Create the window panel. windowPanel.uiSize = new Vector2(sizeX, sizeY); windowPanel.uiRayCast = true; UiManager.CreateBackgroundObj(windowRef, windowPanel).transform.parent.gameObject.AddComponent <QuickUiAnimator>().PlayFadeAnim(0, 1, false, false, 9f); UiBackgroundObject xpcInfoPanel = new UiBackgroundObject(); xpcInfoPanel.uiPosition = new Vector2(-108.07f, -15.12f); xpcInfoPanel.uiSize = new Vector2(284.07f, 340.45f); xpcInfoPanel.uiColor = new Color(0.9f, 0.9f, 0.9f, 1); UiManager.CreateBackgroundObj(windowRef, xpcInfoPanel); UiTextObject windowTitle = new UiTextObject(); windowTitle.uiTextColor = new Color(0, 0, 0, 255); windowTitle.uiText = WindowGrabName(); windowTitle.uiSize = new Vector2(180, 19); windowTitle.uiTextAlign = TextAnchor.UpperCenter; windowTitle.uiPosition = new Vector2(0, 180); UiManager.CreateTextObj(windowRef, windowTitle); windowTitle.uiTextAlign = TextAnchor.MiddleLeft; windowTitle.uiText = "Sprite ID : " + TargetSprite; windowTitle.uiPosition = new Vector2(131, 140); UiManager.CreateTextObj(windowRef, windowTitle); if (TargetSprite == -1) { windowTitle.uiText = "Pixsel scale : ?"; } else { img = XCPManager.PngToSprite(XCPManager.currentXCP.itemTextures[TargetSprite]); windowTitle.uiText = "Pixsel scale : " + XCPManager.currentXCP.itemTextures[TargetSprite].pixScale; } windowTitle.uiSize = new Vector2(236, 19); windowTitle.uiPosition = new Vector2(158.79f, 120); UiManager.CreateTextObj(windowRef, windowTitle); if (TargetSprite == -1) { windowTitle.uiText = "Resolution : " + " H : ?" + "px W : ?" + " px"; } else { windowTitle.uiText = "Resolution : " + " H : " + img.texture.height + "px W : " + img.texture.width + " px"; } windowTitle.uiSize = new Vector2(236, 19); windowTitle.uiPosition = new Vector2(158.79f, 100); UiManager.CreateTextObj(windowRef, windowTitle); UiButtonObject saveButton = new UiButtonObject(); saveButton.uiPosition = new Vector2(210, -165); saveButton.uiSize = new Vector2(70, 34); saveButton.uiButtonBackgroundObject.uiRayCast = true; saveButton.uiButtonBackgroundObject.uiSize = saveButton.uiSize; saveButton.uiButtonBackgroundObject.uiColor = new Color32(100, 100, 100, 100); saveButton.uiButtonBackgroundObject.normalColor = new Color32(170, 170, 170, 100); saveButton.uiButtonBackgroundObject.hoverColor = new Color32(134, 166, 255, 100); saveButton.uiButtonBackgroundObject.pressedColor = new Color32(0, 150, 255, 100); saveButton.uiButtonIcon.uiColor = new Color32(255, 255, 255, 110); saveButton.uiButtonIcon.uiSize = new Vector2(saveButton.uiSize.x - 2, saveButton.uiSize.y - 2); saveButton.uiButtonText = new UiTextObject(); saveButton.uiButtonText.uiTextColor = new Color32(0, 0, 0, 255); saveButton.uiButtonText.uiTextAlign = TextAnchor.MiddleCenter; saveButton.uiButtonText.uiText = "Close"; openBtn = UiManager.CreateButton(windowRef, saveButton).GetComponent <UiIntractable>(); openBtn.onMouseClickEvent = WindowTerminate; saveButton.uiButtonText.uiText = "Remove"; saveButton.uiSize = new Vector2(100, 34); saveButton.uiPosition = new Vector2(130, -165); newBtn = UiManager.CreateButton(windowRef, saveButton).GetComponent <UiIntractable>(); newBtn.onMouseClickEvent = SpriteRemove; saveButton.uiButtonText.uiText = "Remove"; saveButton.uiButtonBackgroundObject.uiColor = new Color32(255, 0, 0, 255); saveButton.uiButtonBackgroundObject.normalColor = new Color32(255, 0, 0, 255); saveButton.uiButtonBackgroundObject.hoverColor = new Color32(255, 0, 0, 100); saveButton.uiButtonIcon.uiColor = new Color32(255, 255, 255, 50); saveButton.uiSize = new Vector2(100, 34); saveButton.uiPosition = new Vector2(130, -125); newBtn = UiManager.CreateButton(windowRef, saveButton).GetComponent <UiIntractable>(); newBtn.onMouseClickEvent = SpriteRemove; newBtn.gameObject.SetActive(false); saveButton.uiButtonText.uiText = "Import Texture"; saveButton.uiSize = new Vector2(120, 34); saveButton.uiButtonText.uiSize = saveButton.uiSize; saveButton.uiButtonBackgroundObject.uiSize = saveButton.uiSize; saveButton.uiButtonIcon.uiSize = new Vector2(saveButton.uiSize.x - 2, saveButton.uiSize.y - 2); saveButton.uiPosition = new Vector2(-186, -165); editBtn = UiManager.CreateButton(windowRef, saveButton).GetComponent <UiIntractable>(); editBtn.onMouseClickEvent = SpriteEdit; UiBackgroundObject transparacyBg = new UiBackgroundObject(); transparacyBg.uiSize = new Vector2(269, 269); transparacyBg.uiPosition = new Vector2(-109f, 12f); transparacyBg.uiColor = new Color32(255, 255, 255, 255); spritePrew = UiManager.CreateBackgroundObj(windowRef, transparacyBg).GetComponent <Image>(); spritePrew.material = Resources.Load("BerrySystem/Shaders/tran", typeof(Material)) as Material; UiBackgroundObject sprite = new UiBackgroundObject(); transparacyBg.uiSize = new Vector2(260, 260); transparacyBg.uiPosition = new Vector2(-109f, 12f); transparacyBg.uiColor = new Color32(255, 255, 255, 255); spritePrew = UiManager.CreateBackgroundObj(windowRef, transparacyBg).GetComponent <Image>(); spritePrew.sprite = img; spritePrew.preserveAspect = true; // windowRef.AddComponent <QuickUiAnimator>().PlayPosAnim(new Vector2(0, 20), new Vector2(0, 0), false, false, 120f); }
public override void WindowCreate(int sizeX, int sizeY, GameObject windowRef) { targetWindowRef = windowRef; // A realy bad way to overide. sizeX = 520; sizeY = 400; // Create a window shadow. windowShadow.uiObjName = "Shadow"; windowShadow.uiTextureRef = Resources.Load <Sprite>("BerrySystem/UI/shadow"); windowShadow.uiColor = new Color32(255, 255, 255, 255); windowShadow.uiSize = new Vector2(sizeX + 90, sizeY + 90); UiManager.CreateBackgroundObj(windowRef, windowShadow); // Create the window panel. windowPanel.uiSize = new Vector2(sizeX, sizeY); windowPanel.uiRayCast = true; UiManager.CreateBackgroundObj(windowRef, windowPanel).transform.parent.gameObject.AddComponent <QuickUiAnimator>().PlayFadeAnim(0, 1, false, false, 9f); UiBackgroundObject xpcInfoPanel = new UiBackgroundObject(); xpcInfoPanel.uiPosition = new Vector2(-108.07f, -15.12f); xpcInfoPanel.uiSize = new Vector2(284.07f, 340.45f); xpcInfoPanel.uiColor = new Color(0.9f, 0.9f, 0.9f, 1); UiManager.CreateBackgroundObj(windowRef, xpcInfoPanel); UiTextObject windowTitle = new UiTextObject(); windowTitle.uiTextColor = new Color(0, 0, 0, 255); windowTitle.uiText = WindowGrabName(); windowTitle.uiSize = new Vector2(180, 19); windowTitle.uiTextAlign = TextAnchor.UpperCenter; windowTitle.uiPosition = new Vector2(0, 180); UiManager.CreateTextObj(windowRef, windowTitle); windowTitle.uiTextAlign = TextAnchor.MiddleLeft; windowTitle.uiText = "Sprite ID : " + TargetSprite; windowTitle.uiPosition = new Vector2(131, 140); UiManager.CreateTextObj(windowRef, windowTitle); windowTitle.uiTextAlign = TextAnchor.MiddleLeft; windowTitle.uiText = "Sprite collider size :"; windowTitle.uiPosition = new Vector2(131, 80); UiManager.CreateTextObj(windowRef, windowTitle); windowTitle.uiTextAlign = TextAnchor.MiddleLeft; windowTitle.uiText = "Sprite collider position :"; windowTitle.uiPosition = new Vector2(131, 30); UiManager.CreateTextObj(windowRef, windowTitle); img = XCPManager.PngToSprite(XCPManager.currentXCP.spriteTextures[TargetSprite]); windowTitle.uiText = "Pixsel scale : " + XCPManager.currentXCP.spriteTextures[TargetSprite].pixScale; windowTitle.uiSize = new Vector2(236, 19); windowTitle.uiPosition = new Vector2(158.79f, 120); UiManager.CreateTextObj(windowRef, windowTitle); windowTitle.uiText = "Resolution : " + " H : " + img.texture.height + "px W : " + img.texture.width + " px"; windowTitle.uiSize = new Vector2(236, 19); windowTitle.uiPosition = new Vector2(158.79f, 100); UiManager.CreateTextObj(windowRef, windowTitle); UiButtonObject saveButton = new UiButtonObject(); saveButton.uiPosition = new Vector2(210, -165); saveButton.uiSize = new Vector2(70, 34); saveButton.uiButtonBackgroundObject.uiRayCast = true; saveButton.uiButtonBackgroundObject.uiSize = saveButton.uiSize; saveButton.uiButtonBackgroundObject.uiColor = new Color32(100, 100, 100, 100); saveButton.uiButtonBackgroundObject.normalColor = new Color32(170, 170, 170, 100); saveButton.uiButtonBackgroundObject.hoverColor = new Color32(134, 166, 255, 100); saveButton.uiButtonBackgroundObject.pressedColor = new Color32(0, 150, 255, 100); saveButton.uiButtonIcon.uiColor = new Color32(255, 255, 255, 110); saveButton.uiButtonIcon.uiSize = new Vector2(saveButton.uiSize.x - 2, saveButton.uiSize.y - 2); saveButton.uiButtonText = new UiTextObject(); saveButton.uiButtonText.uiTextColor = new Color32(0, 0, 0, 255); saveButton.uiButtonText.uiTextAlign = TextAnchor.MiddleCenter; saveButton.uiButtonText.uiText = "Close"; openBtn = UiManager.CreateButton(windowRef, saveButton).GetComponent <UiIntractable>(); openBtn.onMouseClickEvent = WindowTerminate; /* * saveButton.uiButtonText.uiText = "Remove"; * saveButton.uiSize = new Vector2(100, 34); * saveButton.uiPosition = new Vector2(130, -165); * newBtn = UiManager.CreateButton(windowRef, saveButton).GetComponent<UiIntractable>(); * newBtn.onMouseClickEvent = SpriteRemove; * * saveButton.uiButtonText.uiText = "Remove"; * saveButton.uiButtonBackgroundObject.uiColor = new Color32(255, 0, 0, 255); * saveButton.uiButtonBackgroundObject.normalColor = new Color32(255, 0, 0, 255); * saveButton.uiButtonBackgroundObject.hoverColor = new Color32(255, 0, 0, 100); * saveButton.uiButtonIcon.uiColor = new Color32(255, 255, 255, 50); * saveButton.uiSize = new Vector2(100, 34); * saveButton.uiPosition = new Vector2(130, -125); * newBtn = UiManager.CreateButton(windowRef, saveButton).GetComponent<UiIntractable>(); * newBtn.onMouseClickEvent = SpriteRemove; * newBtn.gameObject.SetActive(false); */ saveButton.uiButtonText.uiText = "Done"; saveButton.uiButtonBackgroundObject.uiColor = new Color32(100, 100, 100, 100); saveButton.uiButtonBackgroundObject.normalColor = new Color32(170, 170, 170, 100); saveButton.uiButtonBackgroundObject.hoverColor = new Color32(134, 166, 255, 100); saveButton.uiButtonIcon.uiColor = new Color32(255, 255, 255, 110); saveButton.uiSize = new Vector2(100, 34); saveButton.uiPosition = new Vector2(-210.2f, -165); editDoneBtn = UiManager.CreateButton(windowRef, saveButton).GetComponent <UiIntractable>(); editDoneBtn.onMouseClickEvent = SpriteEditDone; editDoneBtn.gameObject.SetActive(false); /* * saveButton.uiButtonText.uiText = "Is AI"; * saveButton.uiButtonBackgroundObject.uiColor = new Color32(100, 100, 100, 100); * saveButton.uiButtonBackgroundObject.normalColor = new Color32(170, 170, 170, 100); * saveButton.uiButtonBackgroundObject.hoverColor = new Color32(134, 166, 255, 100); * saveButton.uiButtonIcon.uiColor = new Color32(255, 255, 255, 110); * saveButton.uiSize = new Vector2(100, 34); * saveButton.uiPosition = new Vector2(210, -125); * editDoneBtn = UiManager.CreateButton(windowRef, saveButton).GetComponent<UiIntractable>(); * editDoneBtn.onMouseClickEvent = SpriteEditDone; */ saveButton.uiButtonText.uiText = "Set sorting point"; saveButton.uiSize = new Vector2(120, 34); saveButton.uiButtonText.uiSize = saveButton.uiSize; saveButton.uiButtonBackgroundObject.uiSize = saveButton.uiSize; saveButton.uiButtonIcon.uiSize = new Vector2(saveButton.uiSize.x - 2, saveButton.uiSize.y - 2); saveButton.uiPosition = new Vector2(-186, -165); editBtn = UiManager.CreateButton(windowRef, saveButton).GetComponent <UiIntractable>(); editBtn.onMouseClickEvent = SpriteEdit; UiBackgroundObject transparacyBg = new UiBackgroundObject(); transparacyBg.uiSize = new Vector2(269, 269); transparacyBg.uiPosition = new Vector2(-109f, 12f); transparacyBg.uiColor = new Color32(255, 255, 255, 255); spritePrew = UiManager.CreateBackgroundObj(windowRef, transparacyBg).GetComponent <Image>(); spritePrew.material = Resources.Load("BerrySystem/Shaders/bgTran", typeof(Material)) as Material; UiBackgroundObject sprite = new UiBackgroundObject(); transparacyBg.uiSize = new Vector2(260, 260); transparacyBg.uiPosition = new Vector2(-109f, 12f); transparacyBg.uiColor = new Color32(255, 255, 255, 255); spritePrew = UiManager.CreateBackgroundObj(windowRef, transparacyBg).GetComponent <Image>(); spritePrew.sprite = img; spritePrew.preserveAspect = true; UiSliderObject slider0 = new UiSliderObject(); slider0.uiButtonBackgroundObject = new UiInteractiveBackgroundObject(); slider0.uiButtonBackgroundObject.uiSize = new Vector2(200, 32); slider0.uiPosition = new Vector2(-73.8f, -163.8f); slider0.uiButtonBackgroundObject.normalColor = new Color(1, 1, 1, 0.3f); slider0.uiButtonBackgroundObject.uiRayCast = true; slider0.uiButtonIcon = null; slider0.uiButtonText = new UiTextObject(); slider0.uiButtonText.uiText = " Sorting Point"; slider0.uiButtonText.uiSize = new Vector2(200, 32); slider0.uiButtonText.uiTextColor = new Color(0, 0, 0, 1); Slider0 = UiManager.CreateSlider(windowRef, slider0); Slider0.maxValue = 1; Slider0.minValue = 0; Slider0.wholeNumbers = false; Slider0.gameObject.SetActive(false); Slider0.value = XCPManager.currentXCP.spriteTextures[TargetSprite].sortPoint; Slider0.onValueChanged.AddListener(delegate { SortUpdate(); }); UiBackgroundObject sortPoint = new UiBackgroundObject(); sortPoint.uiPosition = new Vector2(-109f, 12f); sortPoint.uiSize = new Vector2(8, 8); sortPoint.uiColor = new Color(1, 0.2f, 0.2f, 1); sortPointObj = UiManager.CreateBackgroundObj(windowRef, sortPoint).GetComponent <Image>(); sortPointObj.transform.localPosition = new Vector3(-109f, Slider0.value * 260 - 120, 0); UiBackgroundObject ColiderBox = new UiBackgroundObject(); ColiderBox.uiTextureRef = Resources.Load <Sprite>("BerrySystem/Textures/Misc/trigger"); ColiderBox.uiPosition = new Vector2(-109f, 12f); ColiderBox.uiSize = new Vector2(16, 16); ColiderBox.uiColor = new Color(0, 1f, 0f, 1); ColiderBoxObj = UiManager.CreateBackgroundObj(windowRef, ColiderBox).GetComponent <Image>(); // windowRef.AddComponent <QuickUiAnimator>().PlayPosAnim(new Vector2(0, 20), new Vector2(0, 0), false, false, 120f); }