Esempio n. 1
0
        // Grab map data and start making tha map and it's objects from the data.
        public static void MapDataCreateMapObj()
        {
            // Create the map data object.
            if (mapDataMapObj == null)
            {
                mapDataMapObj = new GameObject("Map " + XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].map);
                for (int i = 0; i < XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers.Length; i++)
                {
                    // Create eathc layer as a object.
                    XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].layerObjRef = new GameObject(XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].layerName);
                    XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].layerObjRef.transform.SetParent(mapDataMapObj.transform);

                    // Create the map layers.
                    if (XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].chunkClusters != null)
                    {
                        for (int cc = 0; cc < XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].chunkClusters.Length; cc++)
                        {
                            GameObject newChunkCluster = new GameObject(cc.ToString());
                            newChunkCluster.transform.position = MapDataConverter.V2ToVector2(XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].chunkClusters[cc].posId);
                            newChunkCluster.transform.SetParent(XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].layerObjRef.transform);
                            XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].chunkClusters[cc].clusterObjRef = newChunkCluster;

                            if (XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].chunkClusters[cc].chunks != null)
                            {
                                for (int c = 0; c < XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].chunkClusters[cc].chunks.Length; c++)
                                {
                                    GameObject newChunk = new GameObject(c.ToString());
                                    newChunk.transform.SetParent(XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].chunkClusters[cc].clusterObjRef.transform);
                                    newChunk.transform.position = new Vector3(XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].chunkClusters[cc].chunks[c].posId.x, 0, XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].chunkClusters[cc].chunks[c].posId.y);
                                    newChunk.AddComponent <MeshFilter>();
                                    newChunk.AddComponent <MeshRenderer>();
                                    TileMesh2D cTileMap = newChunk.AddComponent <TileMesh2D>();
                                    cTileMap.curCunk    = XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].chunkClusters[cc].chunks[c];
                                    cTileMap.gridOffset = new Vector3(-5.12f, 0, -5.12f);
                                    cTileMap.gridSizeX  = 32;
                                    cTileMap.gridSizeY  = 32;
                                    cTileMap.cellSize   = 0.32f;
                                    cTileMap.StartGenerate();
                                    cTileMap.GenerateSprites();
                                    XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].chunkClusters[cc].chunks[c].chunkObjRef = newChunk;
                                }
                            }
                        }
                    }

                    // Check if this is the main layer.
                    if (XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].mainLayer)
                    {
                        mapDataCurrentLayer = i;
                        mapDataMainLayer    = i;
                    }
                    else
                    {
                        XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[i].layerObjRef.SetActive(false);
                    }
                }
            }
            SwitchLayer(mapDataMainLayer, true);
            CameraManager.UpdateCurrentCamera();
        }
Esempio n. 2
0
        // Update the (chunk or tile layer) mesh renderer to display an updated version of z (chunk or tile layer).
        public void UpdateMesh()
        {
            // Clear the mesh and asign new data to the renderer.
            curMesh.Clear();
            curMesh.vertices  = verts;
            curMesh.triangles = tris;
            curMesh.uv        = uvs;

            // Set the material(s)
            curRenderer.sharedMaterial = ScenePrimer.StandardWorld;
            curRenderer.GetPropertyBlock(curPropBlock);
            if (curCunk.textureId[currentLayer] != 0)
            {
                //Debug.Log(XCPManager.currentXCP.tileIds.Length);
                //Debug.Log(curCunk.textureId[currentLayer]);
                curPropBlock.SetTexture("_tex", XCPManager.PngToTex(XCPManager.currentXCP.tileTextures[curCunk.textureId[currentLayer]]));
            }
            else
            {
                curPropBlock.SetTexture("_tex", XCPManager.PngToTex(XCPManager.currentXCP.tileTextures[curCunk.textureId[currentLayer]]));
            }
            curPropBlock.SetColor("_col", MapDataConverter.ColToColor32(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].forColor));
            curRenderer.SetPropertyBlock(curPropBlock);

            curRenderer.sortingOrder      = -1000 + currentLayer;
            curRenderer.sortingLayerName  = "tilelayer";
            curRenderer.shadowCastingMode = ShadowCastingMode.Off;
            curRenderer.receiveShadows    = false;
        }
Esempio n. 3
0
        // Draws from standard unity update
        public void Update()
        {
            if (curAnimation != null)
            {
                AnimationSprite.GetPropertyBlock(curPropBlock);
                AnimationSprite.sprite = curAnimation.animationFrames[animeStep].frameSprite;
                curPropBlock.SetTexture("_tex", AnimationSprite.sprite.texture);
                curPropBlock.SetColor("_col", MapDataConverter.ColToColor32(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].forColor));
                AnimationSprite.SetPropertyBlock(curPropBlock);

                if (animTime >= 1)
                {
                    if (animeStep == animLength)
                    {
                        if (curAnimation.animationLoop)
                        {
                            animeStep = 0;
                        }
                        else
                        {
                            curAnimation = null;
                        }
                    }
                    else
                    {
                        animeStep++;
                    }
                    animTime = 0;
                }
                else
                {
                    animTime = animTime + animSpeed * Time.deltaTime;
                }
            }
        }
Esempio n. 4
0
 public static void UpdateCurrentCamera()
 {
     if (curCamera != null)
     {
         curCamera.backgroundColor   = MapDataConverter.ColToColor32(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].bgColor);
         RenderSettings.ambientLight = MapDataConverter.ColToColor32(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].forColor);
     }
 }
Esempio n. 5
0
 // 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);
             }
         }
     }
 }
Esempio n. 6
0
 public virtual void CreatePlayer()
 {
     targetPlayerObj = new GameObject("Player");
     targetPlayerObj.transform.SetParent(primerParrentObj.transform);
     targetPlayerObj.transform.position  = MapDataConverter.V3ToVector3(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].layerSpawn);
     targetPlayerObj.transform.position += new Vector3(0, 0.5f);
     targetPlayEntityAgent = targetPlayerObj.AddComponent <PlayerTopDown>();
     targetPlayEntityAgent.CreateEntity("PlayerGameObject");
     targetPlayEntityAgent.playerCameraObj.GetComponent <Camera>().clearFlags = CameraClearFlags.Depth;
     GL.Clear(true, true, new Color(0, 0, 0, 1), 1);
 }
Esempio n. 7
0
        // Saves the mapdata
        public static MapData QueryMapData()
        {
            MapData curMapData = new MapData();

            curMapData.mapCams = new CamInstance[CameraManager.CameraRefs.Length];
            for (int i = 0; i < curMapData.mapCams.Length; i++)
            {
                curMapData.mapCams[i]     = new CamInstance();
                curMapData.mapCams[i].pos = MapDataConverter.Vector3ToV3(CameraManager.CameraRefs[i].transform.position);
                curMapData.mapCams[i].rot = MapDataConverter.QuaternionToV3(CameraManager.CurrentRenderCamera.transform.rotation);
            }

            return(curMapData);
        }
Esempio n. 8
0
 public void UpdateSpriteRendering(Sprite overrideSprite = null)
 {
     AnimationSprite.GetPropertyBlock(curPropBlock);
     if (overrideSprite != null)
     {
         AnimationSprite.sprite = overrideSprite;
     }
     else
     {
         AnimationSprite.sprite = curAnimation.animationFrames[animeStep].frameSprite;
     }
     curPropBlock.SetTexture("_tex", AnimationSprite.sprite.texture);
     curPropBlock.SetColor("_col", MapDataConverter.ColToColor32(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].forColor));
     AnimationSprite.SetPropertyBlock(curPropBlock);
 }
Esempio n. 9
0
 // Switches the current layer to the layer with that index.
 public static void SwitchLayer(int layerIndex, bool instantSwitch = false)
 {
     XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[mapDataCurrentLayer].layerObjRef.SetActive(false);
     mapDataCurrentLayer = layerIndex;
     XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[layerIndex].layerObjRef.SetActive(true);
     if (ScenePrimer.curEditorPrimer != null)
     {
         GameObject.Destroy(ScenePrimer.curGamePrimer);
         if (EditorPrimer.SpawnIcon != null)
         {
             EditorPrimer.SpawnIcon.transform.position = MapDataConverter.V3ToVector3(XCPManager.currentXCP.xpcMaps[mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].layerSpawn);
         }
     }
     CameraManager.UpdateCurrentCamera();
 }
Esempio n. 10
0
        public override void ToolActivation()
        {
            UiManager.DestroyAllFocus();
            BPlacerTool toolWindowType = new BPlacerTool();

            toolWindowType.targetTool = this;
            toolWindow = WindowManager.CreateWindow(200, 100, toolWindowType, true, true);
            if (toolActiveSetterIcon != null)
            {
            }
            GlobalToolManager.globalToolManager.ToolSelectorDeactivate();
            curTileSelector.tileSelectionEnabled = false;
            tileSize = MapDataManager.mapDataTileSize;

            Icon = EditorPrimer.SpawnIconRenderer;
            Icon.transform.position  = MapDataConverter.V3ToVector3(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].layerSpawn);
            Icon.transform.position += new Vector3(0, 0.4f, 0);
            usesDrag = true;
        }
Esempio n. 11
0
        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);
                }
            }
        }
Esempio n. 12
0
        public override void CreateEntity(string entityName = "PlayerObj")
        {
            // Setup the player EntityAgent & rigidbody
            // transform.eulerAngles = new Vector2(90, 0);
            entityObj       = gameObject;
            entityRigidbody = entityObj.AddComponent <Rigidbody>();
            entityRigidbody.interpolation  = RigidbodyInterpolation.Interpolate;
            entityRigidbody.freezeRotation = true;
            entityRigidbody.transform.SetParent(transform);
            entityRigidbody.useGravity = false;
            entityRigidbody.drag       = 9;

            //
            //entityBoxCollider = entityObj.AddComponent<BoxCollider>();
            //entityBoxCollider.size = new Vector3(0.24f,2,0.48f);

            entityFeetCollider = new GameObject("Feet").AddComponent <CapsuleCollider>();
            entityFeetCollider.gameObject.transform.SetParent(entityObj.transform);
            entityFeetCollider.transform.localPosition = new Vector3(0, 0, 0);
            entityFeetCollider.radius = 0.06f;
            entityFeetCollider.height = 2;
            entityFeetCollider.tag    = "feet";

            // Setup a new camera obj
            playerCameraObj = CameraManager.SetupNewCamera(ScenePrimer.curPrimerComponent.primerParrentObj, "PlayerCamera", true, true, 1, new Color(), new Vector3(entityObj.transform.position.x, 2, entityObj.transform.position.z), new Vector3(90, 0, 0));
            playerCameraObj.AddComponent <OldZoom>();
            playerCameraObj.AddComponent <ObjectFollow>().target = transform;

            // Add the BPlayerController to the camera.
            targetPlayerController = SessionManager.CreateBPlayerController(playerCameraObj);
            targetPlayerController.ControllerUpdateMode(true);
            targetPlayerController.targetEntityAgent            = this;
            targetPlayerController.targetRigidbody              = entityRigidbody;
            targetPlayerController.targetCameraObj              = playerCameraObj;
            targetPlayerController.targetCamera                 = playerCameraObj.GetComponent <Camera>();
            targetPlayerController.targetCamera.backgroundColor = MapDataConverter.ColToColor32(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].bgColor);
            PlayerSetupTextures();
        }
Esempio n. 13
0
        public static Layer CreateMapLayer(string layerName, bool clearLayers = false, bool setToMain = false)
        {
            if (clearLayers)
            {
                XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers = null;
            }

            Layer curNewLayer = new Layer();

            curNewLayer.layerName = layerName;
            curNewLayer.mainLayer = setToMain;
            curNewLayer.bgColor   = MapDataConverter.Color32ToCol(new Color(0, 0.023f, 0.05f, 1));
            curNewLayer.forColor  = MapDataConverter.Color32ToCol(new Color32(255, 255, 255, 255));

            if (XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers == null)
            {
                XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers = new Layer[1];
                curLayerIndex = 0;
                return(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[0] = curNewLayer);
            }

            Array.Resize(ref XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers, XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers.Length + 1);
            return(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers.Length - 1] = curNewLayer);
        }
Esempio n. 14
0
        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);
            }
        }
Esempio n. 15
0
 public override void ToolPrimaryUse()
 {
     if (onToolPrimaryUse != null)
     {
         onToolPrimaryUse.Invoke();
     }
     toolPrimaryTargetPosition   = CameraManager.curCamera.ScreenToWorldPoint(Input.mousePosition);
     toolPrimaryTargetPosition.x = (float)System.Math.Round(toolPrimaryTargetPosition.x, 3);
     toolPrimaryTargetPosition.z = (float)System.Math.Round(toolPrimaryTargetPosition.z, 3);
     //toolPrimaryTargetPosition.z += 0.3f;
     toolPrimaryTargetPosition.y = 0.4f;
     Icon.transform.position     = toolPrimaryTargetPosition;
     Icon.sortingOrder           = SessionManager.SpriteSortByPos(Icon);
     XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].layerSpawn = MapDataConverter.Vector3ToV3(toolPrimaryTargetPosition);
 }
Esempio n. 16
0
 public override void PassColor(Color32 passColor)
 {
     XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].forColor = MapDataConverter.Color32ToCol(passColor);
     CameraManager.UpdateCurrentCamera();
 }
Esempio n. 17
0
        public override void WindowCreate(int sizeX, int sizeY, GameObject windowRef)
        {
            targetWindowRef = windowRef;
            // A realy bad way to overide.
            sizeX = 200;
            sizeY = Screen.height - 64;

            // Create the window panel.
            windowPanel.uiSize       = new Vector2(sizeX, sizeY);
            windowPanel.uiAnchorMode = UiManager.UiAnchorsMode.MiddelLeftStretchVertical;
            windowPanel.uiPosition   = new Vector2(Screen.width / 2 * -1 + sizeX - 68, -32);
            windowPanel.uiRayCast    = true;
            GameObject panel = UiManager.CreateBackgroundObj(windowRef, windowPanel);

            panel.transform.parent.gameObject.AddComponent <QuickUiAnimator>().PlayFadeAnim(0, 1, false, false, 9f);

            // Editor File Menu
            UiButtonObject editorFileMenu = new UiButtonObject();

            editorFileMenu.uiObjName    = "editorFileMenu";
            editorFileMenu.uiAnchorMode = UiManager.UiAnchorsMode.TopLeft;
            editorFileMenu.uiPosition   = new Vector2(100, -24);
            editorFileMenu.uiSize       = new Vector2(185, 32);
            editorFileMenu.uiStaticObj  = true;
            editorFileMenu.uiButtonBackgroundObject.uiColor = new Color32(155, 155, 155, 100);

            editorFileMenu.uiButtonText             = new UiTextObject();
            editorFileMenu.uiButtonText.uiTextAlign = TextAnchor.MiddleCenter;
            editorFileMenu.uiButtonText.uiText      = "Layers";
            editorFileMenu.uiButtonText.uiTextColor = new Color(0, 0, 0, 1);

            editorFileMenu.uiButtonIcon = new UiBackgroundObject();
            editorFileMenu.uiButtonIcon.uiTextureRef = ScenePrimer.curEditorPrimer.editorIcons[18];
            editorFileMenu.uiButtonIcon.uiColor      = new Color(0, 0, 0, 0.5f);
            editorFileMenu.uiButtonIcon.uiSize       = new Vector2(17, 17);
            editorFileMenu.uiButtonIcon.uiPosition   = new Vector2(78, 0);

            editorFileMenu.uiButtonBackgroundObject.uiRayCast    = true;
            editorFileMenu.uiButtonBackgroundObject.uiSize       = new Vector2(185, 32);
            editorFileMenu.uiButtonBackgroundObject.normalColor  = new Color32(170, 170, 170, 70);
            editorFileMenu.uiButtonBackgroundObject.hoverColor   = new Color32(134, 166, 255, 100);
            editorFileMenu.uiButtonBackgroundObject.pressedColor = new Color32(0, 150, 255, 100);
            UiManager.CreateButton(panel, editorFileMenu).gameObject.AddComponent <editorLayersButton>();

            UiTextInputField uiLayerName = new UiTextInputField();

            uiLayerName.uiPosition   = new Vector2(100, -90);
            uiLayerName.uiAnchorMode = UiManager.UiAnchorsMode.TopLeft;
            uiLayerName.uiSize       = new Vector2(185, 32);
            uiLayerName.uiButtonBackgroundObject.uiRayCast    = true;
            uiLayerName.uiButtonBackgroundObject.uiSize       = uiLayerName.uiSize;
            uiLayerName.uiButtonBackgroundObject.uiColor      = new Color32(100, 100, 100, 100);
            uiLayerName.uiButtonBackgroundObject.normalColor  = new Color32(170, 170, 170, 100);
            uiLayerName.uiButtonBackgroundObject.hoverColor   = new Color32(134, 166, 255, 100);
            uiLayerName.uiButtonBackgroundObject.pressedColor = new Color32(0, 150, 255, 100);
            uiLayerName.uiButtonIcon.uiColor  = new Color32(255, 255, 255, 110);
            uiLayerName.uiButtonIcon.uiSize   = new Vector2(uiLayerName.uiSize.x - 2, uiLayerName.uiSize.y - 2);
            uiLayerName.uiButtonText          = new UiTextObject();
            uiLayerName.uiButtonText.uiText   = XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].layerName;
            uiLayerName.fieldName             = new UiTextObject();
            uiLayerName.fieldName.uiTextColor = new Color32(0, 0, 0, 255);
            uiLayerName.fieldName.uiTextAlign = TextAnchor.UpperLeft;
            uiLayerName.fieldName.uiSize      = uiLayerName.uiSize;
            uiLayerName.fieldName.uiPosition += new Vector2(3, 25);
            uiLayerName.fieldName.uiText      = "Layer Name";
            InputField inLayerName = UiManager.CreateTextInputField(panel, uiLayerName);

            inLayerName.onEndEdit.AddListener(delegate { SetLayerName(inLayerName.text); });

            UiTextInputField uiLayerBgColor = new UiTextInputField();

            uiLayerBgColor.uiPosition   = new Vector2(100, -189);
            uiLayerBgColor.uiAnchorMode = UiManager.UiAnchorsMode.TopLeft;
            uiLayerBgColor.uiSize       = new Vector2(185, 98);
            uiLayerBgColor.uiButtonBackgroundObject.uiRayCast    = true;
            uiLayerBgColor.uiButtonBackgroundObject.uiSize       = uiLayerBgColor.uiSize;
            uiLayerBgColor.uiButtonBackgroundObject.uiColor      = new Color32(100, 100, 100, 100);
            uiLayerBgColor.uiButtonBackgroundObject.normalColor  = new Color32(170, 170, 170, 100);
            uiLayerBgColor.uiButtonBackgroundObject.hoverColor   = new Color32(134, 166, 255, 100);
            uiLayerBgColor.uiButtonBackgroundObject.pressedColor = new Color32(0, 150, 255, 100);
            uiLayerBgColor.uiButtonIcon.uiColor  = new Color32(255, 255, 255, 110);
            uiLayerBgColor.uiButtonIcon.uiSize   = new Vector2(uiLayerBgColor.uiSize.x - 2, uiLayerBgColor.uiSize.y - 2);
            uiLayerBgColor.fieldName             = new UiTextObject();
            uiLayerBgColor.fieldName.uiTextColor = new Color32(0, 0, 0, 255);
            uiLayerBgColor.fieldName.uiTextAlign = TextAnchor.UpperLeft;
            uiLayerBgColor.fieldName.uiSize      = uiLayerBgColor.uiSize;
            uiLayerBgColor.fieldName.uiPosition += new Vector2(3, 25);
            uiLayerBgColor.fieldName.uiText      = "Background Color";
            UiManager.CreateColorInputField(panel, uiLayerBgColor, MapDataConverter.ColToColor32(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].bgColor), new RunnerLayerBGColor());

            UiTextInputField uiLayerFgColor = new UiTextInputField();

            uiLayerFgColor.uiPosition   = new Vector2(100, -321.8f);
            uiLayerFgColor.uiAnchorMode = UiManager.UiAnchorsMode.TopLeft;
            uiLayerFgColor.uiSize       = new Vector2(185, 98);
            uiLayerFgColor.uiButtonBackgroundObject.uiRayCast    = true;
            uiLayerFgColor.uiButtonBackgroundObject.uiSize       = uiLayerFgColor.uiSize;
            uiLayerFgColor.uiButtonBackgroundObject.uiColor      = new Color32(100, 100, 100, 100);
            uiLayerFgColor.uiButtonBackgroundObject.normalColor  = new Color32(170, 170, 170, 100);
            uiLayerFgColor.uiButtonBackgroundObject.hoverColor   = new Color32(134, 166, 255, 100);
            uiLayerFgColor.uiButtonBackgroundObject.pressedColor = new Color32(0, 150, 255, 100);
            uiLayerFgColor.uiButtonIcon.uiColor  = new Color32(255, 255, 255, 110);
            uiLayerFgColor.uiButtonIcon.uiSize   = new Vector2(uiLayerFgColor.uiSize.x - 2, uiLayerFgColor.uiSize.y - 2);
            uiLayerFgColor.fieldName             = new UiTextObject();
            uiLayerFgColor.fieldName.uiTextColor = new Color32(0, 0, 0, 255);
            uiLayerFgColor.fieldName.uiTextAlign = TextAnchor.UpperLeft;
            uiLayerFgColor.fieldName.uiSize      = uiLayerFgColor.uiSize;
            uiLayerFgColor.fieldName.uiPosition += new Vector2(3, 25);
            uiLayerFgColor.fieldName.uiText      = "Forground Color";
            UiManager.CreateColorInputField(panel, uiLayerFgColor, MapDataConverter.ColToColor32(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].forColor), new RunnerLayerFGColor());

            UiButtonObject uiLayerPlayerSpawn = new UiButtonObject();

            uiLayerPlayerSpawn.uiPosition   = new Vector2(100, -398.27f);
            uiLayerPlayerSpawn.uiAnchorMode = UiManager.UiAnchorsMode.TopLeft;
            uiLayerPlayerSpawn.uiSize       = new Vector2(185, 32);
            uiLayerPlayerSpawn.uiButtonBackgroundObject.uiRayCast    = true;
            uiLayerPlayerSpawn.uiButtonBackgroundObject.uiSize       = uiLayerPlayerSpawn.uiSize;
            uiLayerPlayerSpawn.uiButtonBackgroundObject.uiColor      = new Color32(100, 100, 100, 100);
            uiLayerPlayerSpawn.uiButtonBackgroundObject.normalColor  = new Color32(170, 170, 170, 100);
            uiLayerPlayerSpawn.uiButtonBackgroundObject.hoverColor   = new Color32(134, 166, 255, 100);
            uiLayerPlayerSpawn.uiButtonBackgroundObject.pressedColor = new Color32(0, 150, 255, 100);
            uiLayerPlayerSpawn.uiButtonIcon.uiColor     = new Color32(255, 255, 255, 110);
            uiLayerPlayerSpawn.uiButtonIcon.uiSize      = new Vector2(uiLayerPlayerSpawn.uiSize.x - 2, uiLayerPlayerSpawn.uiSize.y - 2);
            uiLayerPlayerSpawn.uiButtonText             = new UiTextObject();
            uiLayerPlayerSpawn.uiButtonText.uiTextAlign = TextAnchor.MiddleCenter;
            uiLayerPlayerSpawn.uiButtonText.uiText      = "Set player spawn point";
            uiLayerPlayerSpawn.uiButtonText.uiTextColor = new Color(0, 0, 0, 1);
            uiLayerPlayerSpawn.uiButtonText.uiSize      = new Vector2(185, 32);
            EditorToolIndicator setSpawn = UiManager.CreateButton(panel, uiLayerPlayerSpawn).gameObject.AddComponent <EditorToolIndicator>();
            EditorToolPosition  tool     = new EditorToolPosition();

            tool.toolActiveSetterIcon = Resources.Load <Sprite>("BerrySystem/Textures/Topdown/alphaSpawn");
            setSpawn.targetTool       = tool;

            uiLayerPlayerSpawn.uiPosition          = new Vector2(100, -434.1f);
            uiLayerPlayerSpawn.uiButtonText.uiText = "Main Layer : " + XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].mainLayer;
            if (XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].mainLayer)
            {
                UiManager.CreateButton(panel, uiLayerPlayerSpawn);
            }
            else
            {
                UiIntractable setToMain = UiManager.CreateButton(panel, uiLayerPlayerSpawn).GetComponent <UiIntractable>();
                setToMain.onMouseClickEvent = SetLayerMain;
            }

            windowRef.AddComponent <QuickUiAnimator>().PlayPosAnim(new Vector2(-230, 0), new Vector2(0, 0), false, false, 1800f);
        }
Esempio n. 18
0
        public override void PrimerInitialize()
        {
            primerModeName = "Editor Mode";
            worldMaterial  = ScenePrimer.StandardWorld;
            spriteMaterial = ScenePrimer.StandardSprite;
            // Create a empty map
            SessionManager.SessionManagerClearRefs();
            editorIcons = Resources.LoadAll <Sprite>("BerrySystem/Icons/editorIcons");

            if (XCPManager.currentXCP == null)
            {
                takesInput = false;
                BXCPManager xcpWin = new BXCPManager();
                xcpWin.windowTitleName = "editorXCPWindow";
                WindowManager.CreateWindow(200, 300, xcpWin, false, true);
                disableInput = true;


                /*
                 * // Display logo.
                 * UiBackgroundObject logo = new UiBackgroundObject();
                 * logo.uiObjName = "Xonomoto logo";
                 * logo.uiTextureRef = Resources.Load<Sprite>("Xonomoto_studios");
                 * logo.uiAnchorMode = UiManager.UiAnchorsMode.TopRight;
                 * UiManager.CreateBackgroundObj(null, logo);
                 */


                return;
            }
            else
            {
            }

            /*
             *          if(MapDataManager.mapDataXCPIndex == -1){
             *                  MapDataManager.mapData = new MapData().createEmptyMapData("New Map", EditorPrimer.editorVersionNumberInternal,"Derelictus");
             *                  MapDataManager.mapDataFileName = "New Map";
             *                  MapDataManager.mapDataTileSize = 0.32f;
             *                  SessionManager.CreateMapLayer("Layer 0", true, true);
             *                  MapDataManager.MapDataCreateMapObj();
             *          }
             */


            // Create the editor camera.
            // = MapDataConverter.Vector3ToV3( new Vector3(0, 5.8f, 12.75f) );
            // = MapDataConverter.Color32ToV3( new Color32(109, 166, 255, 255) );
            if (primerCurCameraObj == null)
            {
                PrimerCreateCamera();
            }
            disableInput = false;

            editorUi = UiManager.CreateCanvas("editorUi", primerParrentObj);

            SpawnIcon                = new GameObject("editorSetterIcon");
            SpawnIconRenderer        = SpawnIcon.AddComponent <SpriteRenderer>();
            SpawnIconRenderer.sprite = Resources.Load <Sprite>("BerrySystem/Textures/Topdown/alphaSpawn1");
            SpawnIconRenderer.transform.eulerAngles = new Vector2(90, 0);
            SpawnIconRenderer.transform.position    = MapDataConverter.V3ToVector3(XCPManager.currentXCP.xpcMaps[MapDataManager.mapDataXCPIndex].mapLayers[MapDataManager.mapDataCurrentLayer].layerSpawn);
            SpawnIconRenderer.transform.position   += new Vector3(0, 0.3f, 0);
            SpawnIconRenderer.sortingOrder          = SessionManager.SpriteSortByPos(SpawnIconRenderer);

            spriteIcon         = new GameObject("editorSpritePrew");
            spriteIconRenderer = spriteIcon.AddComponent <SpriteRenderer>();
            spriteIconRenderer.transform.eulerAngles = new Vector2(90, 0);
            spriteIconRenderer.transform.position   += new Vector3(0, 0.4f, 0);
            spriteIconRenderer.material = spriteMaterial;
            spriteIcon.AddComponent <MoveAlong>().Icon = spriteIconRenderer;
            spriteIcon.SetActive(false);


            /*
             */
            editorGridObj = new GameObject("editorGrid");
            editorGridObj.transform.SetParent(primerParrentObj.transform);
            editorGridObj.AddComponent <CameraGrid2D>();

            worldGrid2D = new GameObject("World2DGrid");
            worldGrid2D.transform.SetParent(primerParrentObj.transform);
            worldGrid2D.AddComponent <WorldGrid2D>();
            editorUiStatic = UiManager.CreateCanvas("EditorStatic", editorUi, false, true, 0, false);
            UiManager.SetUiAnchors(editorUiStatic, UiManager.UiAnchorsMode.FillStretch);

            // Editor side bar
            UiBackgroundObject editorSideBar = new UiBackgroundObject();

            editorSideBar.uiObjName    = "editorSideBar";
            editorSideBar.uiPosition   = new Vector2(16, 0);
            editorSideBar.uiSize       = new Vector2(32, 0);
            editorSideBar.uiColor      = new Color32(0, 115, 180, 255);
            editorSideBar.uiAnchorMode = UiManager.UiAnchorsMode.MiddelLeftStretchVertical;
            UiManager.CreateBackgroundObj(editorUiStatic, editorSideBar);

            // Editor side bar
            UiBackgroundObject editorTextureWindow = new UiBackgroundObject();

            editorTextureWindow.uiObjName    = "editorTexture";
            editorTextureWindow.uiPosition   = new Vector2(74, 40);
            editorTextureWindow.uiSize       = new Vector2(70, 70);
            editorTextureWindow.uiRayCast    = true;
            editorTextureWindow.uiColor      = new Color32(255, 255, 255, 250);
            editorTextureWindow.uiAnchorMode = UiManager.UiAnchorsMode.BottomLeft;
            texturePrew = UiManager.CreateBackgroundObj(editorUiStatic, editorTextureWindow).GetComponent <Image>();
            texturePrew.preserveAspect = true;
            if (ScenePrimer.curEditorPrimer.curTileId == -1)
            {
                ScenePrimer.curEditorPrimer.curTileId = 0;
            }

            // Editor Window Title Bar
            UiBackgroundObject editorWindowTitleBar = new UiBackgroundObject();

            editorWindowTitleBar.uiObjName    = "editorWindowTitleBar";
            editorWindowTitleBar.uiPosition   = new Vector2(0, -16);
            editorWindowTitleBar.uiSize       = new Vector2(0, 32);
            editorWindowTitleBar.uiColor      = new Color32(40, 170, 224, 255);
            editorWindowTitleBar.uiAnchorMode = UiManager.UiAnchorsMode.TopStretchHorizontal;
            UiManager.CreateBackgroundObj(editorUiStatic, editorWindowTitleBar);

            // Editor Tool Bar
            UiBackgroundObject editorToolBar = new UiBackgroundObject();

            editorToolBar.uiObjName    = "editorToolBar";
            editorToolBar.uiPosition   = new Vector2(0, -48);
            editorToolBar.uiSize       = new Vector2(0, 32);
            editorToolBar.uiColor      = new Color(0, 0.552f, 0.807f, 1f);
            editorToolBar.uiAnchorMode = UiManager.UiAnchorsMode.TopStretchHorizontal;
            UiManager.CreateBackgroundObj(editorUiStatic, editorToolBar);

            editorInteractive = UiManager.CreateCanvas("EditorInteractive", editorUi, false, true, 0, true);
            UiManager.SetUiAnchors(editorInteractive, UiManager.UiAnchorsMode.FillStretch);

            UiTextObject editorTileLayerInfo = new UiTextObject();

            editorTileLayerInfo.uiObjName    = "editorTileLayerInfo";
            editorTileLayerInfo.uiAnchorMode = UiManager.UiAnchorsMode.BottomLeft;
            editorTileLayerInfo.uiTextColor  = new Color(1, 1, 1, 1);
            editorTileLayerInfo.uiText       = "Layer : " + curLayer;
            editorTileLayerInfo.uiTextAlign  = TextAnchor.MiddleCenter;
            editorTileLayerInfo.uiPosition   = new Vector2(74, 90);
            editorTileLayerInfo.uiSize       = new Vector2(70, 70);
            tileInfo = UiManager.CreateTextObj(editorInteractive, editorTileLayerInfo).GetComponent <Text>();

            UiButtonObject editorGridButton = new UiButtonObject();

            editorGridButton.uiObjName                          = "editorGridButton";
            editorGridButton.uiPosition                         = new Vector2(-16, -48);
            editorGridButton.uiSize                             = new Vector2(32, 33);
            editorGridButton.uiButtonIcon.uiSize                = new Vector2(32, 32);
            editorGridButton.uiButtonIcon.uiTextureRef          = editorIcons[5];
            editorGridButton.uiAnchorMode                       = UiManager.UiAnchorsMode.TopRight;
            editorGridButton.uiButtonBackgroundObject.uiRayCast = true;
            editorGridButton.uiButtonBackgroundObject.uiSize    = new Vector2(32, 32);
            editorGridButton.uiButtonBackgroundObject.uiColor   = new Color32(255, 255, 255, 0);

            UiManager.CreateButton(editorInteractive, editorGridButton).gameObject.AddComponent <EditorGridBtn>();

            UiTextObject mapTitle = new UiTextObject();

            mapTitle.uiObjName    = "editorTitle";
            mapTitle.uiTextAlign  = TextAnchor.MiddleCenter;
            mapTitle.uiAnchorMode = UiManager.UiAnchorsMode.TopStretchHorizontal;
            mapTitle.uiSize       = new Vector2(32, 32);
            mapTitle.uiPosition   = new Vector2(0, -16);
            mapTitle.uiText       = MapDataManager.mapDataFileName;
            editorMapTitle        = UiManager.CreateTextObj(editorInteractive, mapTitle);

            // Editor File Menu
            UiButtonObject editorFileMenu = new UiButtonObject();

            editorFileMenu.uiObjName    = "editorFileMenu";
            editorFileMenu.uiAnchorMode = UiManager.UiAnchorsMode.TopLeft;
            editorFileMenu.uiPosition   = new Vector2(25, -48);
            editorFileMenu.uiSize       = new Vector2(50, 32);
            editorFileMenu.uiStaticObj  = true;
            editorFileMenu.uiButtonBackgroundObject.uiColor = new Color32(255, 255, 255, 0);

            editorFileMenu.uiButtonText             = new UiTextObject();
            editorFileMenu.uiButtonText.uiTextAlign = TextAnchor.MiddleCenter;
            editorFileMenu.uiButtonText.uiText      = "File";

            editorFileMenu.uiButtonIcon = null;

            editorFileMenu.uiButtonBackgroundObject.uiRayCast    = true;
            editorFileMenu.uiButtonBackgroundObject.uiSize       = new Vector2(50, 32);
            editorFileMenu.uiButtonBackgroundObject.normalColor  = new Color32(255, 255, 255, 0);
            editorFileMenu.uiButtonBackgroundObject.hoverColor   = new Color32(255, 255, 255, 40);
            editorFileMenu.uiButtonBackgroundObject.pressedColor = new Color32(255, 255, 255, 70);
            UiManager.CreateButton(editorInteractive, editorFileMenu).onMouseClickEvent = ClickFileBtn;

            // Editor Editor Menu
            UiButtonObject editorEditorMenu = new UiButtonObject();

            editorEditorMenu.uiObjName    = "editorEditorMenu";
            editorEditorMenu.uiAnchorMode = UiManager.UiAnchorsMode.TopLeft;
            editorEditorMenu.uiPosition   = new Vector2(80, -48);
            editorEditorMenu.uiSize       = new Vector2(60, 32);
            editorEditorMenu.uiStaticObj  = true;
            editorEditorMenu.uiButtonBackgroundObject.uiColor = new Color32(255, 255, 255, 0);

            editorEditorMenu.uiButtonText             = new UiTextObject();
            editorEditorMenu.uiButtonText.uiTextAlign = TextAnchor.MiddleCenter;
            editorEditorMenu.uiButtonText.uiText      = "Editor";

            editorEditorMenu.uiButtonIcon = null;

            editorEditorMenu.uiButtonBackgroundObject.uiRayCast    = true;
            editorEditorMenu.uiButtonBackgroundObject.uiSize       = new Vector2(60, 32);
            editorEditorMenu.uiButtonBackgroundObject.normalColor  = new Color32(255, 255, 255, 0);
            editorEditorMenu.uiButtonBackgroundObject.hoverColor   = new Color32(255, 255, 255, 40);
            editorEditorMenu.uiButtonBackgroundObject.pressedColor = new Color32(255, 255, 255, 70);
            UiManager.CreateButton(editorInteractive, editorEditorMenu).onMouseClickEvent = ClickEditBtn;

            // Editor Editor Menu
            UiButtonObject editorLevelMode = new UiButtonObject();

            editorLevelMode.uiObjName    = "editorLevelMode";
            editorLevelMode.uiAnchorMode = UiManager.UiAnchorsMode.TopCenter;
            editorLevelMode.uiPosition   = new Vector2(-30, -48);
            editorLevelMode.uiSize       = new Vector2(60, 32);
            editorLevelMode.uiStaticObj  = true;
            editorLevelMode.uiButtonBackgroundObject.uiColor = new Color32(255, 255, 255, 0);

            editorLevelMode.uiButtonText             = new UiTextObject();
            editorLevelMode.uiButtonText.uiTextAlign = TextAnchor.MiddleCenter;
            editorLevelMode.uiButtonText.uiText      = "Level";

            editorLevelMode.uiButtonIcon = null;

            editorLevelMode.uiButtonBackgroundObject.uiRayCast    = true;
            editorLevelMode.uiButtonBackgroundObject.uiSize       = new Vector2(60, 32);
            editorLevelMode.uiButtonBackgroundObject.normalColor  = new Color32(255, 255, 255, 30);
            editorLevelMode.uiButtonBackgroundObject.hoverColor   = new Color32(255, 255, 255, 40);
            editorLevelMode.uiButtonBackgroundObject.pressedColor = new Color32(255, 255, 255, 70);
            UiManager.CreateButton(editorInteractive, editorLevelMode);

            // Editor Editor Menu
            UiButtonObject editorUiMode = new UiButtonObject();

            editorUiMode.uiObjName    = "editorUiMode";
            editorUiMode.uiAnchorMode = UiManager.UiAnchorsMode.TopCenter;
            editorUiMode.uiPosition   = new Vector2(30, -48);
            editorUiMode.uiSize       = new Vector2(60, 32);
            editorUiMode.uiStaticObj  = true;
            editorUiMode.uiButtonBackgroundObject.uiColor = new Color32(255, 255, 255, 0);

            editorUiMode.uiButtonText             = new UiTextObject();
            editorUiMode.uiButtonText.uiTextAlign = TextAnchor.MiddleCenter;
            editorUiMode.uiButtonText.uiText      = "Ui";

            editorUiMode.uiButtonIcon = null;

            editorUiMode.uiButtonBackgroundObject.uiRayCast    = true;
            editorUiMode.uiButtonBackgroundObject.uiSize       = new Vector2(60, 32);
            editorUiMode.uiButtonBackgroundObject.normalColor  = new Color32(255, 255, 255, 0);
            editorUiMode.uiButtonBackgroundObject.hoverColor   = new Color32(255, 255, 255, 40);
            editorUiMode.uiButtonBackgroundObject.pressedColor = new Color32(255, 255, 255, 70);
            UiManager.CreateButton(editorInteractive, editorUiMode);

            // Editor Preview Menu
            UiButtonObject preview = new UiButtonObject();

            preview.uiObjName    = "editorPreview";
            preview.uiAnchorMode = UiManager.UiAnchorsMode.TopRight;
            preview.uiPosition   = new Vector2(-64, -48);
            preview.uiSize       = new Vector2(60, 32);
            preview.uiStaticObj  = true;
            preview.uiButtonBackgroundObject.uiColor = new Color32(255, 255, 255, 0);

            preview.uiButtonText             = new UiTextObject();
            preview.uiButtonText.uiTextAlign = TextAnchor.MiddleCenter;
            preview.uiButtonText.uiText      = "Preview";

            preview.uiButtonIcon = null;

            preview.uiButtonBackgroundObject.uiRayCast    = true;
            preview.uiButtonBackgroundObject.uiSize       = new Vector2(60, 32);
            preview.uiButtonBackgroundObject.normalColor  = new Color32(255, 255, 255, 0);
            preview.uiButtonBackgroundObject.hoverColor   = new Color32(255, 255, 255, 40);
            preview.uiButtonBackgroundObject.pressedColor = new Color32(255, 255, 255, 70);
            UiManager.CreateButton(editorInteractive, preview).onMouseClickEvent = ClickPreviewBtn;

            // Create fps and millisecond display.
            UiTextObject editorWindowTitle = new UiTextObject();

            editorWindowTitle.uiObjName    = "editorWindowTitle";
            editorWindowTitle.uiText       = "Construi";
            editorWindowTitle.uiPosition   = new Vector2(40, -15);
            editorWindowTitle.uiSize       = new Vector2(60, 32);
            editorWindowTitle.uiTextColor  = new Color(1, 1, 1, 1f);
            editorWindowTitle.uiTextSize   = 12;
            editorWindowTitle.uiAnchorMode = UiManager.UiAnchorsMode.TopStretchHorizontal;
            UiManager.CreateTextObj(editorUiStatic, editorWindowTitle);

            // Create fps and millisecond display.
            UiTextObject editorFps = new UiTextObject();

            editorFps.uiObjName    = "editorFps";
            editorFps.uiPosition   = new Vector2(120, -15);
            editorFps.uiSize       = new Vector2(90, 32);
            editorFps.uiTextColor  = new Color(1, 1, 1, 1f);
            editorFps.uiTextSize   = 12;
            editorFps.uiAnchorMode = UiManager.UiAnchorsMode.TopStretchHorizontal;
            UiManager.CreateTextObj(editorUiStatic, editorFps).AddComponent <FPSDisplay>();

            // Create pentool.
            UiButtonObject editorLayerSettings = new UiButtonObject();

            editorLayerSettings.uiObjName                          = "editorLayerSettings";
            editorLayerSettings.uiPosition                         = new Vector2(16, -80);
            editorLayerSettings.uiSize                             = new Vector2(32, 32);
            editorLayerSettings.uiButtonIcon.uiSize                = new Vector2(32, 32);
            editorLayerSettings.uiButtonBackgroundObject.uiSize    = new Vector2(32, 32);
            editorLayerSettings.uiButtonBackgroundObject.uiRayCast = true;
            editorLayerSettings.uiAnchorMode                       = UiManager.UiAnchorsMode.TopLeft;
            editorLayerSettings.uiButtonIcon.uiTextureRef          = editorIcons[16];
            UiManager.CreateButton(editorInteractive, editorLayerSettings).onMouseClickEvent = ClickLayerBtn;

            UiButtonObject editorTexturePanel = new UiButtonObject();

            editorTexturePanel.uiObjName                          = "editorTexturePanel";
            editorTexturePanel.uiPosition                         = new Vector2(16, -112);
            editorTexturePanel.uiSize                             = new Vector2(32, 32);
            editorTexturePanel.uiButtonIcon.uiSize                = new Vector2(32, 32);
            editorTexturePanel.uiButtonBackgroundObject.uiSize    = new Vector2(32, 32);
            editorTexturePanel.uiButtonBackgroundObject.uiRayCast = true;
            editorTexturePanel.uiAnchorMode                       = UiManager.UiAnchorsMode.TopLeft;
            editorTexturePanel.uiButtonIcon.uiTextureRef          = editorIcons[7];
            UiManager.CreateButton(editorInteractive, editorTexturePanel).onMouseClickEvent = ClickTexturesBtn;

            UiButtonObject editorSpritePanel = new UiButtonObject();

            editorTexturePanel.uiObjName                          = "editorTexturePanel";
            editorTexturePanel.uiPosition                         = new Vector2(16, -112 - 32);
            editorTexturePanel.uiSize                             = new Vector2(32, 32);
            editorTexturePanel.uiButtonIcon.uiSize                = new Vector2(32, 32);
            editorTexturePanel.uiButtonBackgroundObject.uiSize    = new Vector2(32, 32);
            editorTexturePanel.uiButtonBackgroundObject.uiRayCast = true;
            editorTexturePanel.uiAnchorMode                       = UiManager.UiAnchorsMode.TopLeft;
            editorTexturePanel.uiButtonIcon.uiTextureRef          = editorIcons[28];
            UiManager.CreateButton(editorInteractive, editorTexturePanel).onMouseClickEvent = ClickSpritePanelBtn;

            UiButtonObject editorEntityPanel = new UiButtonObject();

            editorEntityPanel.uiObjName                          = "editorEntityPanel";
            editorEntityPanel.uiPosition                         = new Vector2(16, -112 - 64);
            editorEntityPanel.uiSize                             = new Vector2(32, 32);
            editorEntityPanel.uiButtonIcon.uiSize                = new Vector2(32, 32);
            editorEntityPanel.uiButtonBackgroundObject.uiSize    = new Vector2(32, 32);
            editorEntityPanel.uiButtonBackgroundObject.uiRayCast = true;
            editorEntityPanel.uiAnchorMode                       = UiManager.UiAnchorsMode.TopLeft;
            editorEntityPanel.uiButtonIcon.uiTextureRef          = editorIcons[37];
            UiManager.CreateButton(editorInteractive, editorEntityPanel).onMouseClickEvent = ClickEntityPanelBtn;

            UiButtonObject editorItemPanel = new UiButtonObject();

            editorItemPanel.uiObjName                          = "editorItemPanel";
            editorItemPanel.uiPosition                         = new Vector2(16, -112 - 64 - 32);
            editorItemPanel.uiSize                             = new Vector2(32, 32);
            editorItemPanel.uiButtonIcon.uiSize                = new Vector2(32, 32);
            editorItemPanel.uiButtonBackgroundObject.uiSize    = new Vector2(32, 32);
            editorItemPanel.uiButtonBackgroundObject.uiRayCast = true;
            editorItemPanel.uiAnchorMode                       = UiManager.UiAnchorsMode.TopLeft;
            editorItemPanel.uiButtonIcon.uiTextureRef          = editorIcons[36];
            UiManager.CreateButton(editorInteractive, editorItemPanel).onMouseClickEvent = ClickItemPanelBtn;

            // Create editor tool manager
            curEditorToolManager = GlobalToolManager.CreateGlobalToolManager(primerParrentObj);

            // Create pentool.
            UiButtonObject editorPenTool = new UiButtonObject();

            editorPenTool.uiObjName                          = "editorPenTool";
            editorPenTool.uiPosition                         = new Vector2(16, 32);
            editorPenTool.uiSize                             = new Vector2(32, 32);
            editorPenTool.uiButtonIcon.uiSize                = new Vector2(32, 32);
            editorPenTool.uiButtonBackgroundObject.uiSize    = new Vector2(32, 32);
            editorPenTool.uiButtonBackgroundObject.uiRayCast = true;
            editorPenTool.uiAnchorMode                       = UiManager.UiAnchorsMode.BottomLeft;
            editorPenTool.uiButtonIcon.uiTextureRef          = editorIcons[1];

            curEditorToolManager.EditorTools[0].curToolIndicator                     = UiManager.CreateButton(editorInteractive, editorPenTool).gameObject.AddComponent <EditorToolIndicator>();
            curEditorToolManager.EditorTools[0].curToolIndicator.targetTool          = curEditorToolManager.EditorTools[0];
            curEditorToolManager.EditorTools[0].curToolIndicator.toolActivatedIcon   = editorIcons[12];
            curEditorToolManager.EditorTools[0].curToolIndicator.toolDeActivatedIcon = editorIcons[1];

            UiButtonObject EditorToolEraserPen = new UiButtonObject();

            EditorToolEraserPen.uiObjName                          = "editorToolEraserPen";
            EditorToolEraserPen.uiPosition                         = new Vector2(16, 64);
            EditorToolEraserPen.uiSize                             = new Vector2(32, 32);
            EditorToolEraserPen.uiButtonIcon.uiSize                = new Vector2(32, 32);
            EditorToolEraserPen.uiButtonBackgroundObject.uiSize    = new Vector2(32, 32);
            EditorToolEraserPen.uiButtonBackgroundObject.uiRayCast = true;
            EditorToolEraserPen.uiAnchorMode                       = UiManager.UiAnchorsMode.BottomLeft;
            EditorToolEraserPen.uiButtonIcon.uiTextureRef          = editorIcons[17];

            curEditorToolManager.EditorTools[1].curToolIndicator                     = UiManager.CreateButton(editorInteractive, EditorToolEraserPen).gameObject.AddComponent <EditorToolIndicator>();
            curEditorToolManager.EditorTools[1].curToolIndicator.targetTool          = curEditorToolManager.EditorTools[1];
            curEditorToolManager.EditorTools[1].curToolIndicator.toolActivatedIcon   = editorIcons[18];
            curEditorToolManager.EditorTools[1].curToolIndicator.toolDeActivatedIcon = editorIcons[17];

            UiButtonObject editorFillTool = new UiButtonObject();

            editorFillTool.uiObjName                          = "editorFillTool";
            editorFillTool.uiPosition                         = new Vector2(16, 96);
            editorFillTool.uiSize                             = new Vector2(32, 32);
            editorFillTool.uiButtonIcon.uiSize                = new Vector2(32, 32);
            editorFillTool.uiButtonBackgroundObject.uiSize    = new Vector2(32, 32);
            editorFillTool.uiButtonBackgroundObject.uiRayCast = true;
            editorFillTool.uiAnchorMode                       = UiManager.UiAnchorsMode.BottomLeft;
            editorFillTool.uiButtonIcon.uiTextureRef          = editorIcons[0];

            curEditorToolManager.EditorTools[2].curToolIndicator                     = UiManager.CreateButton(editorInteractive, editorFillTool).gameObject.AddComponent <EditorToolIndicator>();
            curEditorToolManager.EditorTools[2].curToolIndicator.targetTool          = curEditorToolManager.EditorTools[2];
            curEditorToolManager.EditorTools[2].curToolIndicator.toolActivatedIcon   = editorIcons[11];
            curEditorToolManager.EditorTools[2].curToolIndicator.toolDeActivatedIcon = editorIcons[0];

            UiButtonObject editorSelect = new UiButtonObject();

            editorSelect.uiObjName                          = "editorSelect";
            editorSelect.uiPosition                         = new Vector2(16, 128);
            editorSelect.uiSize                             = new Vector2(32, 32);
            editorSelect.uiButtonIcon.uiSize                = new Vector2(32, 32);
            editorSelect.uiButtonBackgroundObject.uiSize    = new Vector2(32, 32);
            editorSelect.uiButtonBackgroundObject.uiRayCast = true;
            editorSelect.uiAnchorMode                       = UiManager.UiAnchorsMode.BottomLeft;
            editorSelect.uiButtonIcon.uiTextureRef          = editorIcons[26];

            curEditorToolManager.EditorTools[3].curToolIndicator                     = UiManager.CreateButton(editorInteractive, editorSelect).gameObject.AddComponent <EditorToolIndicator>();
            curEditorToolManager.EditorTools[3].curToolIndicator.targetTool          = curEditorToolManager.EditorTools[2];
            curEditorToolManager.EditorTools[3].curToolIndicator.toolActivatedIcon   = editorIcons[25];
            curEditorToolManager.EditorTools[3].curToolIndicator.toolDeActivatedIcon = editorIcons[26];

            UiButtonObject editorLineMesh = new UiButtonObject();

            editorLineMesh.uiObjName                          = "editorLineMesh";
            editorLineMesh.uiPosition                         = new Vector2(16, 128 + 32);
            editorLineMesh.uiSize                             = new Vector2(32, 32);
            editorLineMesh.uiButtonIcon.uiSize                = new Vector2(32, 32);
            editorLineMesh.uiButtonBackgroundObject.uiSize    = new Vector2(32, 32);
            editorLineMesh.uiButtonBackgroundObject.uiRayCast = true;
            editorLineMesh.uiAnchorMode                       = UiManager.UiAnchorsMode.BottomLeft;
            editorLineMesh.uiButtonIcon.uiTextureRef          = editorIcons[30];

            curEditorToolManager.EditorTools[5].curToolIndicator                     = UiManager.CreateButton(editorInteractive, editorLineMesh).gameObject.AddComponent <EditorToolIndicator>();
            curEditorToolManager.EditorTools[5].curToolIndicator.targetTool          = curEditorToolManager.EditorTools[5];
            curEditorToolManager.EditorTools[5].curToolIndicator.toolActivatedIcon   = editorIcons[32];
            curEditorToolManager.EditorTools[5].curToolIndicator.toolDeActivatedIcon = editorIcons[30];

            editorCreated = true;
            takesInput    = true;

            UpdateTexturePrew();
        }