// PRIVATE METHODS: -------------------------------------------------------------------------------------------- private void DropAreaGUI(bool photonPrefab = true) { UnityEngine.Event evt = UnityEngine.Event.current; Rect drop_area = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true)); Rect text_area = drop_area; GUI.Box(drop_area, "", "ShurikenEffectBg"); GUIStyle style = EditorStyles.centeredGreyMiniLabel; if (!InternalEditorUtility.HasPro()) { style.normal.textColor = Color.white; } EditorGUI.LabelField(text_area, "To Add a new prefab just drag and drop it here.", style); switch (evt.type) { case EventType.DragUpdated: case EventType.DragPerform: if (!drop_area.Contains(evt.mousePosition)) { return; } DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (evt.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); foreach (UnityEngine.Object draggedObject in DragAndDrop.objectReferences) { if (draggedObject is GameObject) { if (PrefabUtility.GetPrefabAssetType(draggedObject) == PrefabAssetType.Regular || PrefabUtility.GetPrefabAssetType(draggedObject) == PrefabAssetType.Variant) //!photonPrefab || (photonPrefab { GameObject go = draggedObject as GameObject; if (photonPrefab && DatabasePhoton.IsDefaultPrefab(go)) { bool result = EditorUtility.DisplayDialog("Error", "Cannot use default prefabs.\nDo you want to create a copy?", "Ok", "Cancel"); if (result) { go = DatabasePhoton.CreatePrefabCopy(go); } else { return; } } if (go == null) { return; } if (photonPrefab && go.GetComponent <PhotonView>() == null) { EditorUtility.DisplayDialog("Error", string.Format("This prefab needs to have a Photon View.", PrefabUtility.GetPrefabAssetType(draggedObject)), "Ok"); return; } serializedObject.Update(); if (photonPrefab) { if (!inst.prefabs.Contains(go)) { serializedObject.FindProperty("prefabs").AddToObjectArray(go); //inst.prefabs.Add(go); AssetDatabase.SaveAssets(); } } else { if (!inst.attachments.Contains(go)) { serializedObject.FindProperty("attachments").AddToObjectArray(go); //inst.attachments.Add(go); AssetDatabase.SaveAssets(); } } serializedObject.ApplyModifiedProperties(); } else { EditorUtility.DisplayDialog("Error", string.Format("Only Prefabs are allowed. Type: {0}", PrefabUtility.GetPrefabAssetType(draggedObject)), "Ok"); } } else { EditorUtility.DisplayDialog("Error", string.Format("Only GameObjects are allowed. Type: {0}", draggedObject), "Ok"); } } if (GUI.changed) { EditorUtility.SetDirty(inst); } } break; } }