Example #1
0
    private void Start()
    {
        isAboutToCancel = false;
        lastXfill       = 0;
        lastZfill       = 0;
        lastDistanceZ   = 0;
        lastDistanceX   = 0;
        heightStep      = 1;
        isBuilding      = false;
        lastDistance    = new Vector3(-10000, -10000, -10000);
        mDummy          = (GameObject)Resources.Load("uteForEditor/uteTcDummy");
        mDummyMat       = (Material)Resources.Load("uteForEditor/uteTcDummyMat");
#if UNITY_EDITOR
        uteMEE     = this.gameObject.GetComponent <uteMapEditorEngine>();
        UndoSystem = this.gameObject.GetComponent <uteUndoSystem>();

        if (!uteMEE)
        {
#endif
        uteMEER = this.gameObject.GetComponent <uteMapEditorEngineRuntime>();
#if UNITY_EDITOR
    }
#endif
    }
	private void Start()
	{
		isAboutToCancel = false;
		lastXfill = 0;
		lastZfill = 0;
		lastDistanceZ = 0;
		lastDistanceX = 0;
		heightStep = 1;
		isBuilding = false;
		lastDistance = new Vector3(-10000,-10000,-10000);
		mDummy = (GameObject) Resources.Load("uteForEditor/uteTcDummy");
		mDummyMat = (Material) Resources.Load("uteForEditor/uteTcDummyMat");
#if UNITY_EDITOR
		uteMEE = this.gameObject.GetComponent<uteMapEditorEngine>();
		UndoSystem = this.gameObject.GetComponent<uteUndoSystem>();

		if(!uteMEE)
		{
#endif
			uteMEER = this.gameObject.GetComponent<uteMapEditorEngineRuntime>();
#if UNITY_EDITOR
		}
#endif
	}
	public IEnumerator uteInitMapEditorEngine()
	{
		rotationList.Add(0);
		rotationList.Add(90);
		rotationList.Add(180);
		rotationList.Add(270);
		
		isTileRandomizerEnabled = false;
		isTileRandomizerRotationEnabled = false;
		eraserIsEnabled = false;
		isAltPressed = false;
		isInTopView = false;
		currentTCID = 0;
		lastTile = null;
		currentLayer = 0;
		isContinuesBuild = false;
		isMouseDown = false;
		isBuildingTC = false;
		isShowCameraOptions = false;
		isCamGridMoving = false;
		isBuildingMass = false;
		isCommandPressed = false;
		isControlPressed = false;
		uteGLOBAL3dMapEditor.canBuild = true;
		editorIsLoading = true;
		canBuild = false;
		cameraGO = (GameObject) GameObject.Find("MapEditorCamera");
		uteGLOBAL3dMapEditor.isEditorRunning = true;
		cameraOptionsRect = new Rect(Screen.width-505,Screen.height-70,410,30);
		uteHelp = (uteHelpBox) this.gameObject.AddComponent<uteHelpBox>();
		ui = (GUISkin) Resources.Load("uteForEditor/uteUI");
		catInfoPath = AssetDatabase.GUIDToAssetPath(uteGLOBAL3dMapEditor.uteCategoryInfotxt);
		settingsInfoPath = AssetDatabase.GUIDToAssetPath(uteGLOBAL3dMapEditor.uteSettingstxt);
		GUIComboBoxCollider = new Rect(10, 0, 200, 30);
		GUIComboBoxColliderTC = new Rect(10,0,200,30);

		gridsize = new Vector3(1000.0f,0.1f,1000.0f);
		previewObjTexture = new Texture2D(25,25);
		previewObjTextureTC = new Texture2D(25,25);
		erase = false;
		currentTcFamilyName = "";
		currentObjectGUID = "";
			
		currentFilter = "";
		lastFilter = "_______!@#$%*&(*^*&(^*&";

		MAP = new GameObject("MAP");
		MAP_DYNAMIC = new GameObject("MAP_DYNAMIC");
		MAP_DYNAMIC.transform.parent = MAP.transform;
		MAP_STATIC = new GameObject("MAP_STATIC");
		MAP_STATIC.transform.parent = MAP.transform;
		MAP_STATIC.isStatic = true;
		mapLightGO = (GameObject) Instantiate((GameObject) Resources.Load("uteForEditor/uteMapLight"));
		mapLightGO.name = "MapLight";
		GameObject tempGO = new GameObject();
		tempGO.name = "TEMP";

		LayersEngine = (uteLayersEngine) this.gameObject.AddComponent<uteLayersEngine>();
		LayersEngine.ReadLayersFromMap(newProjectName,MAP_STATIC,MAP_DYNAMIC,this);

		previewT = new Texture2D(2,2);
		previewTTC = new Texture2D(2,2);

		isShowLineHelpers = false;
		GameObject help = (GameObject) Instantiate((GameObject)Resources.Load("uteForEditor/uteHELPERS"),Vector3.zero,Quaternion.identity);
		help.name = "uteHELPERS";
		helpers_CANTBUILD = GameObject.Find("uteHELPERS/CANTBUILD");
		helpers_CANBUILD = GameObject.Find("uteHELPERS/CANBUILD");
		InitHelperLines();

		uTCE = (uteTileConnectionsEngine) this.gameObject.AddComponent<uteTileConnectionsEngine>();
		uMBE = (uteMassBuildEngine) this.gameObject.AddComponent<uteMassBuildEngine>();

		yield return StartCoroutine(ReloadTileAssets());

		uteOptions = (uteOptionsBox) this.gameObject.AddComponent<uteOptionsBox>();
		saveMap.options = uteOptions;

		UndoSystem = (uteUndoSystem) this.gameObject.AddComponent<uteUndoSystem>();

		StartCoroutine(EraserHandler());

		if(isItLoad)
		{
			_uteLM = this.gameObject.AddComponent<uteLM>();
			_uteLM.uMEE = this;
			yield return StartCoroutine(_uteLM.LoadMap(newProjectName,MAP_STATIC,MAP_DYNAMIC,isItNewMap));
			yield return StartCoroutine(LoadCameraInfo());
			yield return StartCoroutine(uteOptions.LoadOptions());
			yield return StartCoroutine(AssignLayersToTiles());
			editorIsLoading = false;
			LayersEngine.CheckIfAllTilesHasExistingLayer();
		}
		else
		{
			editorIsLoading = false;
		}

		if(!isItLoad)
		{
			yield return StartCoroutine(saveMap.SaveMap(newProjectName,isItNewMap));
		}

		yield return 0;
	}