public void UpdateGridData() { gridData.worldOrigin = new Vector2( utils.GetContextToWorldX(state.gridOriginX), utils.GetContextToWorldY(state.gridOriginY) ); gridData.worldZero = new Vector2( utils.GetContextToWorldX(0f), utils.GetContextToWorldY(0f)); gridData.worldUnit = new Vector2( utils.GetContextToWorldX(state.gridX), utils.GetContextToWorldY(state.gridY)); gridData.worldUnitSize = gridData.worldUnit - gridData.worldZero; gridData.worldWidth = state.gridCols * gridData.worldUnitSize.x; gridData.worldHeight = state.gridRows * gridData.worldUnitSize.y; gridData.worldCorner = new Vector2( gridData.worldOrigin.x + gridData.worldWidth, gridData.worldOrigin.y + gridData.worldHeight ); }
void CompleteGuideCreation() { if (creatingHGuide) { if (state.snapGuideToInt) { int contextY = Mathf.RoundToInt(utils.GetWorldToContextY(liveGuide.y)); liveGuide.y = utils.GetContextToWorldY(contextY); } // pure zero is reserved for logical testing if (liveGuide.y == 0) { liveGuide.y = Globals.FALSE_ZERO; } state.hGuides.Add(liveGuide.y.ToString()); } else { if (state.snapGuideToInt) { int contextX = Mathf.RoundToInt(utils.GetWorldToContextX(liveGuide.x)); liveGuide.x = utils.GetContextToWorldX(contextX); } // pure zero is reserved for logical testing if (liveGuide.x == 0) { liveGuide.x = Globals.FALSE_ZERO; } state.vGuides.Add(liveGuide.x.ToString()); } liveGuide = Vector2.zero; creatingHGuide = false; creatingVGuide = false; state.displayGuides = true; utils.RepaintEditorWindow(); }