Exemple #1
0
    //======================================================================================================================================
    // Socket Tools
    //======================================================================================================================================

    private void DrawSocketTools()
    {
        EditorGUILayout.BeginVertical();
        if (viewModel.DrawSockets != EditorGUILayout.Toggle("Show Socket Axes In View", viewModel.DrawSockets))
        {
            viewModel.SetDrawSockets(!viewModel.DrawSockets);
        }

        foreach (string targetSocketName in viewModel.GetPreviewTargetSocketNames())
        {
            EditorGUILayout.BeginHorizontal();
            if (viewModel.GetPreviewSocketEnabled(targetSocketName) != EditorGUILayout.Toggle(viewModel.GetPreviewSocketEnabled(targetSocketName)))
            {
                viewModel.SetPreviewSocketEnabled(targetSocketName, !viewModel.GetPreviewSocketEnabled(targetSocketName));
            }
            NPVoxIMeshFactory selectedFactory    = viewModel.GetPreviewFactoryForTargetSocket(targetSocketName);
            NPVoxIMeshFactory newSelectedFactory = NPipelineUtils.DrawSourceSelector(targetSocketName, selectedFactory);
            if (selectedFactory != newSelectedFactory)
            {
                viewModel.SetPreviewFactoryForTargetSocket(targetSocketName, newSelectedFactory);
            }

            string[] sourceSockets = viewModel.GetSourceSocketsForTargetSocket(targetSocketName);
            if (sourceSockets == null || sourceSockets.Length == 0)
            {
                GUILayout.Label("No Socket");
            }
            else
            {
                string selectedSourceSocket    = viewModel.GetSourceSocketForTargetSocket(targetSocketName);
                string newSelectedSourceSocket = NPipeGUILayout.Popup(sourceSockets, sourceSockets, selectedSourceSocket, true);
                if (selectedSourceSocket != newSelectedSourceSocket)
                {
                    viewModel.SetSourceSocketForTargetSocket(targetSocketName, newSelectedSourceSocket);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndVertical();
    }
Exemple #2
0
    public override void OnInspectorGUI()
    {
        GUIStyle boldStyle = new GUIStyle();

        boldStyle.fontStyle = FontStyle.Bold;

        NPVoxAnimation animation = (NPVoxAnimation)target;

        GUILayout.Label("NPVox Animation: " + animation.name);

        GUILayout.Label("Tools:");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Invalidate & Reimport All"))
        {
            NPipelineUtils.InvalidateAndReimportAll(animation);
        }
        if (GUILayout.Button("Invalidate & Reimport All Deep"))
        {
            NPipelineUtils.InvalidateAndReimportAllDeep(animation);
        }
        GUILayout.EndHorizontal();

        if (GUILayout.Button("Edit Animation"))
        {
            OpenAnimationScene(animation);
        }

        if (animation.Frames != null && animation.Frames.Length > 0 && animation.Frames[0].Source != null)
        {
            NPVoxModel model = animation.Frames[0].Source.GetProduct();

            if (model != null && model.SocketNames.Length > 0)
            {
                EditorGUILayout.BeginHorizontal();
                selectedTargetSocket = NPipeGUILayout.Popup(model.SocketNames, model.SocketNames, selectedTargetSocket, true);
                selectedModelFactory = NPipelineUtils.DrawSourceSelector <NPVoxIModelFactory>("Input:", selectedModelFactory);

                if (selectedModelFactory != null && selectedModelFactory.GetProduct())
                {
                    selectedInputSocket = NPipeGUILayout.Popup(selectedModelFactory.GetProduct().SocketNames, selectedModelFactory.GetProduct().SocketNames, selectedInputSocket, true);
                }

                if (GUILayout.Button("Create Slave Animation") && selectedModelFactory != null)
                {
                    createSlaveAnimation(animation, selectedTargetSocket, selectedModelFactory, selectedInputSocket);
                }

                if (GUILayout.Button("Create Slave Animation From Preview") && selectedModelFactory != null)
                {
                    createSlaveAnimationFromPreview(animation, selectedModelFactory);
                }

                EditorGUILayout.EndHorizontal();
            }
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        GUILayout.Label("Animation Default Settings", boldStyle);
        DrawDefaultInspector();

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        // Mesh Output Settings

        GUILayout.Label("Mesh Output Settings", boldStyle);
        if (animation.MeshFactory.DrawInspector(~NPipeEditFlags.TOOLS & ~NPipeEditFlags.INPUT))
        {
            // Cascade to all frames
            foreach (NPVoxFrame frame in animation.Frames)
            {
                frame.Output.BloodColorIndex         = animation.MeshFactory.BloodColorIndex;
                frame.Output.Cutout                  = animation.MeshFactory.Cutout;
                frame.Output.Loop                    = animation.MeshFactory.Loop;
                frame.Output.NormalMode              = animation.MeshFactory.NormalMode;
                frame.Output.NormalVariance          = animation.MeshFactory.NormalVariance;
                frame.Output.NormalVarianceSeed      = animation.MeshFactory.NormalVarianceSeed;
                frame.Output.VoxelSize               = animation.MeshFactory.VoxelSize;
                frame.Output.StorageMode             = animation.MeshFactory.StorageMode;
                frame.Output.MinVertexGroups         = animation.MeshFactory.MinVertexGroups;
                frame.Output.NormalModePerVoxelGroup = animation.MeshFactory.NormalModePerVoxelGroup;
            }
        }


        // Destroy unconnected things

        NPipeIImportable[] importables = NPipelineUtils.GetImportables(AssetDatabase.GetAssetPath(animation));
        foreach (NPipeIImportable importable in importables)
        {
            NPipeIImportable prev = NPipelineUtils.FindPreviousOfType <NPVoxIModelFactory>(importable);
            if ((importable as NPVoxMeshOutput) != animation.MeshFactory && (prev == null || prev == importable))
            {
                Debug.LogWarning("Destroying orphaning importable: " + importable);
                if (importable is  NPipeIComposite)
                {
                    ((NPipeIComposite)importable).Input = null;
                }
                importable.Destroy(); // destroy the product
                Undo.DestroyObjectImmediate((UnityEngine.Object)importable);
            }
        }
    }