Example #1
0
        void CTXOnAddTemplate(object userData)
        {
            string tplPath;

            if (TemplatesByMenuName.TryGetValue((string)userData, out tplPath))
            {
                CGEditorUtility.LoadTemplate(Parent.Generator, tplPath, Canvas.MousePosition);
            }
        }
Example #2
0
        void Save()
        {
            string absFolder = Application.dataPath + "/" + CurvyProject.Instance.CustomizationRootPath + CurvyProject.RELPATH_CGTEMPLATES;
            string file      = absFolder + "/" + mName + ".prefab";

            if (!System.IO.File.Exists(file) || EditorUtility.DisplayDialog("Replace File?", "The file already exists! Replace it?", "Yes", "No"))
            {
                if (CGEditorUtility.CreateTemplate(mModules, file))
                {
                    EditorUtility.DisplayDialog("Save Generator Template", "Template successfully saved!", "Ok");
                }
            }
        }
Example #3
0
        public static List <CGModule> LoadTemplate(CurvyGenerator generator, string path, Vector2 canvasPosition)
        {
            var srcGen = AssetDatabase.LoadAssetAtPath(path, typeof(CurvyGenerator)) as CurvyGenerator;

            if (srcGen)
            {
                return(CGEditorUtility.CopyModules(srcGen.Modules, generator, canvasPosition));
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        /// <summary>
        /// Paste all Clipboard modules
        /// </summary>
        /// <param name="target">the generator to paste to</param>
        /// <param name="positionOffset">Canvas offset to use</param>
        /// <returns>the new modules</returns>
        public List <CGModule> PasteModules(CurvyGenerator target, Vector2 positionOffset)
        {
            var res = CGEditorUtility.CopyModules(Modules, target, positionOffset);

            if (Mode == ClipboardMode.Cut)
            {
                foreach (var mod in Modules)
                {
                    ParentGenerator.DeleteModule(mod);
                }
            }
            Clear();

            return(res);
        }
Example #5
0
        void DrawToolbar()
        {
            GUILayout.BeginHorizontal(CurvyStyles.Toolbar);
            // Clear
            if (GUILayout.Button(new GUIContent(CurvyStyles.DeleteTexture, "Clear"), EditorStyles.miniButton) && EditorUtility.DisplayDialog("Clear", "Clear graph?", "Yes", "No"))
            {
                Sel.Select(null);
                Generator.Clear();
                Repaint();
                GUIUtility.ExitGUI();
            }

            GUILayout.Space(10);

            // Refresh
            if (GUILayout.Button(new GUIContent(CurvyStyles.RefreshTexture, "Refresh"), EditorStyles.miniButton, GUILayout.ExpandWidth(false)) && !DTGUI.IsLayout)
            {
                Modules = null;
                Generator.Refresh(true);
                Repaint();
                GUIUtility.ExitGUI();
            }

            // Debug
            EditorGUI.BeginChangeCheck();
            mShowDebug.target = GUILayout.Toggle(mShowDebug.target, new GUIContent(CurvyStyles.DebugTexture, "Debug"), EditorStyles.miniButton);
            if (EditorGUI.EndChangeCheck())
            {
                Generator.ShowDebug = mShowDebug.target;
                SceneView.RepaintAll();
            }

            GUILayout.Space(10);


            // Expanded/Collapsed actions
            CurvyProject.Instance.CGAutoModuleDetails = GUILayout.Toggle(CurvyProject.Instance.CGAutoModuleDetails, new GUIContent(CurvyStyles.CGAutoFoldTexture, "Auto-Expand selected module"), EditorStyles.miniButton);
            if (GUILayout.Button(new GUIContent(CurvyStyles.ExpandTexture, "Expand all"), EditorStyles.miniButton))
            {
                CGEditorUtility.SetModulesExpandedState(true, Generator.Modules.ToArray());
            }
            if (GUILayout.Button(new GUIContent(CurvyStyles.CollapseTexture, "Collapse all"), EditorStyles.miniButton))
            {
                CGEditorUtility.SetModulesExpandedState(false, Generator.Modules.ToArray());
            }
            // Sync Selection
            CurvyProject.Instance.CGSynchronizeSelection = GUILayout.Toggle(CurvyProject.Instance.CGSynchronizeSelection, new GUIContent(CurvyStyles.SynchronizeTexture, "Synchronize Selection"), EditorStyles.miniButton);

            // Save Template
            GUILayout.Space(10);
            GUI.enabled = Sel.SelectedModule != null;
            if (GUILayout.Button(new GUIContent(CurvyStyles.AddTemplateTexture, "Save Selection as Template"), EditorStyles.miniButton))
            {
                TemplateWizard.Open(Sel.SelectedModules);
            }

            GUI.enabled = true;
            GUILayout.FlexibleSpace();
            GUILayout.Label(new GUIContent(CurvyStyles.TexGridSnap, "Grid Size"));
            CurvyProject.Instance.CGGraphSnapping = (int)GUILayout.HorizontalSlider(CurvyProject.Instance.CGGraphSnapping, 1, 20, GUILayout.Width(60));
            GUILayout.Label(CurvyProject.Instance.CGGraphSnapping.ToString(), GUILayout.Width(20));
            CurvyProject.Instance.CGShowHelp = GUILayout.Toggle(CurvyProject.Instance.CGShowHelp, new GUIContent(CurvyStyles.HelpTexture, "Show Help"), EditorStyles.miniButton, GUILayout.Height(20));
            GUILayout.EndHorizontal();
        }