internal void ImportFromArray(Selection selectionState, bool restore = false) { if (selectionState != null && selectionState.states != null && selectionState.states.Length > 0) { HashSet <string> missingPrefabs = new HashSet <string>(); foreach (InstanceState state in selectionState.states) { if (state.Info.Prefab == null) { missingPrefabs.Add(state.prefabName); } } if (missingPrefabs.Count > 0) { DebugUtils.Warning("Missing prefabs: " + string.Join(", ", missingPrefabs.ToArray())); UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Assets missing", "The following assets are missing and will be ignored:\n\n" + string.Join("\n", missingPrefabs.ToArray()), false); } // Set props to fixed-height if in asset editor if ((ToolManager.instance.m_properties.m_mode & ItemClass.Availability.AssetEditor) != ItemClass.Availability.None) { foreach (InstanceState state in selectionState.states) { if (state is PropState ps) { ps.fixedHeight = true; ps.position.y = ps.position.y - ps.terrainHeight + 60f; // 60 is editor's terrain height } } } CloneActionBase action = new CloneActionImport(selectionState.states, selectionState.center); if (action.Count > 0) { ActionQueue.instance.Push(action); if (restore) { SimulationManager.instance.AddAction(() => { ActionQueue.instance.Do(); }); //ActionQueue.instance.Do(); // For restore to position } else { SetToolState(ToolStates.Cloning); // For clone } UIToolOptionPanel.RefreshCloneButton(); UIToolOptionPanel.RefreshAlignHeightButton(); } } }
public virtual void ReplaceInstance(Instance newInstance) { instance = newInstance; if (newInstance.id.Type != instance.id.Type) { DebugUtils.Warning("Mismatching instances type ('" + newInstance.id.Type + "' -> '" + newInstance.id.Type + "')."); } if (newInstance.Info.Prefab != Info.Prefab) { DebugUtils.Warning($"Mismatching instances info:\n{Info.Prefab.name} <{Info.GetHashCode()}>\n{newInstance.Info.Prefab.name} <{newInstance.Info.GetHashCode()}>\n"); } }
public virtual void ReplaceInstance(Instance newInstance) { instance = newInstance; if (newInstance.id.Type != instance.id.Type) { DebugUtils.Warning("Mismatching instances type ('" + newInstance.id.Type + "' -> '" + newInstance.id.Type + "')."); } if (newInstance.info != info) { DebugUtils.Warning("Mismatching instances info ('" + info.name + "' -> '" + newInstance.info.name + "')."); } }
private Vector3 GetControlPoint(ushort segment) { Vector3 startPos = nodeBuffer[segmentBuffer[segment].m_startNode].m_position; Vector3 startDir = segmentBuffer[segment].m_startDirection; Vector3 endPos = nodeBuffer[segmentBuffer[segment].m_endNode].m_position; Vector3 endDir = segmentBuffer[segment].m_endDirection; if (!NetSegment.IsStraight(startPos, startDir, endPos, endDir, out float num)) { float dot = startDir.x * endDir.x + startDir.z * endDir.z; if (dot >= -0.999f && Line2.Intersect(VectorUtils.XZ(startPos), VectorUtils.XZ(startPos + startDir), VectorUtils.XZ(endPos), VectorUtils.XZ(endPos + endDir), out float u, out float v)) { return(startPos + startDir * u); } else { DebugUtils.Warning("Invalid segment directions!"); } }