void CopyParameters(ref GameObject waypoint, int newIndex) { //float fltOldIndex = newIndex / (steps + 1); int intOldIndex; int modIndex = newIndex % (steps + 1); if (modIndex == 0) { intOldIndex = newIndex / (steps + 1); } else { intOldIndex = 1 + (newIndex / (steps + 1)); } GameVehicleAIWaypoint oldAiWaypointScript = path[intOldIndex - 1].GetComponent("GameVehicleAIWaypoint") as GameVehicleAIWaypoint; GameVehicleAIWaypoint aiWaypointScript = waypoint.GetComponent("GameVehicleAIWaypoint") as GameVehicleAIWaypoint; aiWaypointScript.speed = oldAiWaypointScript.speed; aiWaypointScript.useTrigger = oldAiWaypointScript.useTrigger; //if (aiWaypointScript.useTrigger) //{ //BoxCollider bc = waypoint.AddComponent<BoxCollider>(); //bc.isTrigger = true; //waypoint.layer = path[intOldIndex - 1].gameObject.layer; Die automatische Zuweisung geschieht erst spaeter //waypoint.layer = 2; /* * BoxCollider bcTest =gameObject.GetComponent<BoxCollider>(); * if (bcTest == null) * { * BoxCollider bc = gameObject.AddComponent<BoxCollider>(); * bc.isTrigger = true; * gameObject.layer = 2; * } * else * { * bcTest.isTrigger = true; * gameObject.layer = 2; * } */ //} waypoint.transform.localScale = path[intOldIndex - 1].localScale; waypoint.tag = path[intOldIndex - 1].gameObject.tag; }
void OnSceneGUI() { if (m_editMode) { if (Event.current.type == EventType.MouseDown) { if (Event.current.button == 0) //2013-08-02 { //2013-08-02 Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); RaycastHit hit; //2011-04-11 cse -B if (m_container == null) { LogUtil.LogError("No container found. Place waypoints in scenes directly after pressing the Waypoint Editor button."); m_editMode = false; Repaint(); } //2011-04-11 cse -E if (m_editMode) //2011-04-11 cse { //2011-04-11 cse if (Physics.Raycast(ray, out hit)) { int counter = 1; string fullPreName; fullPreName = "/" + m_folderName + "/" + m_preName + "_"; while (GameObject.Find(fullPreName + counter.ToString()) != null) { counter++; } //Undo.RegisterUndo("Create new Waypoint"); GameObject prefab = AssetDatabase.LoadAssetAtPath(pathStorage + "Prefabs/Waypoint.prefab", typeof(GameObject)) as GameObject; GameObject waypoint = Instantiate(prefab) as GameObject; Vector3 myPosition; myPosition = hit.point; myPosition.y = (float)myPosition.y + (float)(waypoint.transform.localScale.y / 2); waypoint.transform.position = myPosition; waypoint.name = m_preName + "_" + counter.ToString(); waypoint.transform.parent = m_container.transform; GameVehicleAIWaypoint aiwaypointScript = waypoint.GetComponent("GameVehicleAIWaypoint") as GameVehicleAIWaypoint; aiwaypointScript.speed = m_speed; EditorUtility.SetDirty(waypoint); //rotate last WP GameObject lastWP = GameObject.Find(fullPreName + (counter - 1).ToString()); if (lastWP != null) { lastWP.transform.LookAt(waypoint.transform); EditorUtility.SetDirty(lastWP); } } m_editMode = false; } //2011-04-11 cse } //2013-08-02 } } }