Esempio n. 1
0
    private void AddSelected()
    {
        if (target == null)
        {
            return;
        }
        if (_guidlist.index < 0 || _guidlist.index >= _guidlist.count)
        {
            return;
        }
        string path = AssetDatabase.GUIDToAssetPath(_guids[_guidlist.index]);

        if (typeof(T) == typeof(CornerDesign))
        {
            CornerDesign asset = (CornerDesign)AssetDatabase.LoadAssetAtPath(path, typeof(CornerDesign));
            if (asset == null)
            {
                return;
            }
            Undo.RecordObject(target, "Added CornerDesign to MappingObject");
            target.AddCorner(asset);
            //dirty target object
            EditorUtility.SetDirty(target);
        }
        else if (typeof(T) == typeof(LateralDesign))
        {
            LateralDesign asset = (LateralDesign)AssetDatabase.LoadAssetAtPath(path, typeof(LateralDesign));
            if (asset == null)
            {
                return;
            }
            Undo.RecordObject(target, "Added LatEdgeDesign to MappingObject");
            target.AddLateral(asset);
            //dirty target object
            EditorUtility.SetDirty(target);
        }
        else if (typeof(T) == typeof(LongitudeDesign))
        {
            LongitudeDesign asset = (LongitudeDesign)AssetDatabase.LoadAssetAtPath(path, typeof(LongitudeDesign));
            if (asset == null)
            {
                return;
            }
            Undo.RecordObject(target, "Added LongEdgeDesign to MappingObject");
            target.AddLongitude(asset);
            //dirty target object
            EditorUtility.SetDirty(target);
        }
        else if (typeof(T) == typeof(RectDesign))
        {
            RectDesign asset = (RectDesign)AssetDatabase.LoadAssetAtPath(path, typeof(RectDesign));
            if (asset == null)
            {
                return;
            }
            Undo.RecordObject(target, "Added RectFaceDesign to MappingObject");
            target.AddRect(asset);
            //dirty target object
            EditorUtility.SetDirty(target);
        }
        else if (typeof(T) == typeof(HexagonDesign))
        {
            HexagonDesign asset = (HexagonDesign)AssetDatabase.LoadAssetAtPath(path, typeof(HexagonDesign));
            if (asset == null)
            {
                return;
            }
            Undo.RecordObject(target, "Added HexagonFaceDesign to MappingObject");
            target.AddHexagon(asset);
            //dirty target object
            EditorUtility.SetDirty(target);
        }
        else
        {
            return;
        }
        _repaint_menu = true;
    }