Exemple #1
0
//		private static string[] syncChannelOptions = new string[]{ "None", "Splat", "Node Targets", "Node Children" };

        public void OnEnable()
        {
            painter = (NodePainter)target;
            if (painter.painter == null)
            {
                throw new Exception("Painter not initialized!");
            }
            editor = new PaintingEditor(painter.painter);
            editor.MultiChannelSyncGUI = DrawMultiChannelSyncGUI;

            //GetPreviewTextures ();

            painter.UpdateTerrains();
            GlobalPainting.UpdateTerrainBrush();
            GlobalPainting.HideCanvasProjection();

            if (!System.IO.Directory.Exists(Settings.paintingResourcesFolder))
            {
                Debug.LogWarning("Resource folder does not exist! Please select a valid path in the settings!");
                return;
            }
        }
Exemple #2
0
 public void OnDisable()
 {
     editor.Close();
     GlobalPainting.UpdateTerrainBrush();
     GlobalPainting.HideCanvasProjection();
 }
Exemple #3
0
        public override void OnInspectorGUI()
        {
            if (editor == null)
            {
                return;
            }

            if ((Event.current.type == EventType.MouseUp && Event.current.button == 0) || Event.current.button != 0)
            {
                painter.painter.StopPainting(GUIWindowID);
            }

            editor.GUIWindowID = GUIWindowID;

            if (Event.current.type != EventType.Repaint && Event.current.type != EventType.Layout)
            {
                Undo.RecordObject(painter, "Node Painter Settings");
            }
            string undoRecord;

            editor.DoPainterGUI(out undoRecord);
            if (!string.IsNullOrEmpty(undoRecord))
            {
                Undo.FlushUndoRecordObjects();
                //Debug.Log ("Recording " + undoRecord + " over " + Undo.GetCurrentGroupName () + "!");
            }

            if (painter.painter.hasCanvas)
            {
                expandTargets = EditorGUILayout.Foldout(expandTargets, "Node Targets", PaintingEditor.headerFoldout);
                if (expandTargets)
                {
                    painter.TCArea = (TC_Area2D)EditorGUILayout.ObjectField("TC2 Area 2D", painter.TCArea, typeof(TC_Area2D), true);
                    if (painter.painter.canvasFormat != Painting.Format.Multi && painter.TCNode != null)
                    {
                        GUILayout.Label("Current node: " + painter.TCNode.name);
                    }
                    while (painter.channelTargets.Count < painter.painter.canvasChannelCount || painter.channelTargets.Count < 1)
                    {
                        painter.channelTargets.Add(new NodePainter.ChannelNodeTargets());
                    }
//					painter.painter.curChannelIndex = Mathf.Clamp (painter.painter.curChannelIndex, 0, painter.painter.canvasChannelCount-1);
                    DrawNodeTargetList(painter.channelTargets[painter.painter.curChannelIndex].targets);

                    if (painter.channelTargets.Count == 0)
                    {
                        GUILayout.Label("No node targets specified!");
                    }
                }
            }

            AdditionalGUIUtility.Seperator();

            if (GUILayout.Button("Show Settings", EditorStyles.toolbarButton))
            {
                SettingsWindow.Open();
            }

//			GUILayout.Label ("Painter's control ID: " + editor.controlID);
//			GUILayout.Label ("Active control ID: " + GUIUtility.hotControl);

            EditorGUILayout.Space();

            if (editor.isMouseInWindow)
            {
                Repaint();
            }

            if (vizCanvasOnTerrain != painter.painter.vizCanvasExternally)
            {
                vizCanvasOnTerrain = painter.painter.vizCanvasExternally;
                if (vizCanvasOnTerrain)
                {
                    GlobalPainting.ShowCanvasProjection(painter.transform.position + Vector3.up * TC_Area2D.current.bounds.size.y, painter.transform.rotation,
                                                        new Vector2(painter.transform.localScale.x * painter.TCNodeTarget.size.x, painter.transform.localScale.z * painter.TCNodeTarget.size.z),
                                                        painter.painter.vizCanvas, painter.painter.canvasFormat == Painting.Format.Value);
                }
                else
                {
                    GlobalPainting.HideCanvasProjection();
                }
                HandleUtility.Repaint();
                SceneView.RepaintAll();
            }
        }