Example #1
0
        public static void CreateModifier(Modifier modifier)
        {
            string name = modifier.Name.value.value_str;

            if (string.IsNullOrEmpty(name))
            {
                name = "New Camera Modifier";
            }
            string path = AssetDatabase.GetAssetPath(Selection.activeObject);

            if (path == "")
            {
                path = "Assets";
            }
            else if (Path.GetExtension(path) != "")
            {
                path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
            }

            if (path.Substring(0, 6) != "Assets")
            {
                EditorUtility.DisplayDialog("Please select a target folder first", "Error", "OK");
                return;
            }

            ModifierAsset asset = ScriptableObject.CreateInstance <ModifierAsset>();

            asset.modifier = modifier;
            asset.Save();
            asset.modifier = null;

            path = AssetDatabase.GenerateUniqueAssetPath(path + "/" + name + ".asset");
            AssetDatabase.CreateAsset(asset, path);
            AssetDatabase.SaveAssets();
        }
        public override void OnInspectorGUI()
        {
            if (skin == null)
            {
                skin = Resources.Load <GUISkin>("GUI/EditorSkin") as GUISkin;
            }

            Rect rect;

            GUILayout.Space(10);

            rect = EditorGUILayout.GetControlRect(false, 20);
            Rect _r = rect;

            _r.width = 120;
            _r.y    -= 3;
            EditorGUI.DropShadowLabel(_r, "Camera Modifier");
            //rect = EditorGUILayout.GetControlRect(false, 20);
            rect.xMax -= 15;
            rect.xMin  = rect.xMax - 100;

            if (GUI.Button(rect, "Edit >>"))
            {
                ModifierAsset asset = (target as ModifierAsset);
                if (asset != null)
                {
                    asset.Load(true);
                    CameraForgeWindow.asset = asset;
                    CameraForgeWindow.Init();
                    CameraForgeWindow.current = asset.modifier;
                }
            }
        }
Example #3
0
        static void DragModifierInto()
        {
            if (Event.current == null)
            {
                return;
            }
            var eventType = Event.current.type;

            if (eventType == EventType.DragUpdated || eventType == EventType.DragPerform)
            {
                // Show a copy icon on the drag
                if (DragAndDrop.objectReferences.Length != 1)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                }
                else
                {
                    object        drag_obj   = DragAndDrop.objectReferences[0];
                    ModifierAsset drag_asset = drag_obj as ModifierAsset;
                    if (drag_asset != null)
                    {
                        DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                        if (eventType == EventType.DragPerform)
                        {
                            DragAndDrop.AcceptDrag();
                            ModifierAsset copied_asset = UnityEngine.Object.Instantiate <ModifierAsset>(drag_asset);
                            copied_asset.Load(true);
                            Modifier modifier = copied_asset.modifier;
                            modifier.editorPos = Content2Node(Event.current.mousePosition);
                            controller.AddPoseNode(modifier);
                            ModifierAsset.DestroyImmediate(copied_asset);
                        }
                    }
                    else
                    {
                        DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                    }
                }
                Event.current.Use();
            }
            if (eventType == EventType.DragExited)
            {
                DragAndDrop.PrepareStartDrag();
            }

//			EditorGUILayout.BeginHorizontal ();
//			EditorGUILayout.LabelField ("特效路径", GUILayout.Width (80));
//			Rect sfxPathRect = EditorGUILayout.GetControlRect(GUILayout.Width (250));
//			string sfxPathText = EditorGUI.TextField (sfxPathRect, "");
//
//			if (Event.current != null)
//			{
//				if ( Event.current.type == EventType.DragExited )
//				{
//					Debug.Log(Event.current.mousePosition);
//					if (DragAndDrop.paths != null && DragAndDrop.paths.Length > 0)
//					{
//						DragAndDrop.AcceptDrag ();
//						foreach (string path in DragAndDrop.paths)
//						{
//							if (!string.IsNullOrEmpty(path))
//							{
//								if (Event.current.type == EventType.DragExited)
//								{
//									Debug.Log(path);
//								}
//							}
//						}
//					}
//				}
//			}
//			EditorGUILayout.EndHorizontal ();
//
        }