private void selectPattern(int index) { // No change, do nothing if (index == selectedPatIndex_) return; // Negative index means no selection if (index < 0) { selectedPatIndex_ = -1; return; } // Check bounds if (index >= patternCount_.intValue) { Debug.LogError("can't select pattern beyond bounds: "+index); return; } // successful selection change selectedPatIndex_ = index; // Find inspector for pattern within editor namespace CellPattern pat = patternsArray ()[index]; // Does inspector need instantiating or changing? if (patInspector_==null || !patInspector_.doesInspectPattern(pat.GetType())) { // Yes - so instantiate new corresponding class string classStr = "LevelEditor."+pat.GetType().Name+"Inspector"; Type inspType = Type.GetType(classStr); if (inspType == null) { Debug.LogWarning("No inspector of class '"+classStr+"', defaulting to CellPatternInspector."); inspType = typeof(CellPatternInspector); } patInspector_ = Activator.CreateInstance(inspType) as CellPatternInspector; // If inspecting a FreePattern, we need to pass in the stores dictionary if (patInspector_.GetType() == typeof(FreePatternInspector)) { FreePatternInspector fpInsp = patInspector_ as FreePatternInspector; fpInsp.storesDict = storeEditor_.storesDict; } } patInspector_.setTarget(pat); }
private void clearSelection() { selectedPatIndex_ = -1; patInspector_ = null; }