コード例 #1
0
        public override void OnInspectorGUI()
        {
            var attachment = (UsdPrimSource)target;
            var stageRoot  = attachment.GetComponentInParent <UsdAsset>();

            if (!stageRoot)
            {
                stageRoot = attachment.GetComponent <UsdAsset>();
            }

            if (!stageRoot)
            {
                Debug.LogError("No stage root found");
                return;
            }

            var scene = stageRoot.GetScene();

            if (scene == null)
            {
                Debug.LogError("Invalid scene: " + stageRoot.usdFullPath);
                return;
            }

            var prim = scene.GetPrimAtPath(attachment.m_usdPrimPath);

            //
            // BEGIN GUI.
            //

            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("USD Prim: ", GUILayout.Width(100));
            EditorGUILayout.SelectableLabel(attachment.m_usdPrimPath, EditorStyles.textField,
                                            GUILayout.Height(EditorGUIUtility.singleLineHeight));
            GUILayout.EndHorizontal();

            if (prim != null)
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Prim Type: ", GUILayout.Width(100));
                EditorGUILayout.SelectableLabel(prim.GetTypeName(), EditorStyles.textField,
                                                GUILayout.Height(EditorGUIUtility.singleLineHeight));
                GUILayout.EndHorizontal();
            }

            EditorGUILayout.LabelField("USD Time: " + stageRoot.m_usdTimeOffset);

            m_showExpandedUi = GUILayout.Toggle(m_showExpandedUi, "Show USD Inspector");

            if (!m_showExpandedUi)
            {
                return;
            }

            //
            // Attribute Grid.
            //
            // Separator.
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            if (prim == null)
            {
                EditorGUILayout.LabelField("(Prim is not valid/loaded in USD file)");
                return;
            }

            DrawAttributeGui(prim, scene);

            //
            // Prim Composition Graph.
            //
            // Separator.
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            EditorGUILayout.LabelField("Prim Composition Graph", EditorStyles.boldLabel);

            // Since composition can only happen at the prim level, the prim is used to construct the
            // composition graph. The Pcp (Prim Cache Population) API is the lowest level of the
            // composition system, which means it's most powerful and most complicated. PcpNodeRefs
            // provide direct access to the in-memory composition structure. Note that unloaded prims
            // will not have a PrimIndex.
            //
            // The composition graph is typically less useful for users, since it's a complicated
            // structure to understand, but often there is a small handful of power users on a
            // production responsible for setting up the pipeline composition structure; for them this
            // visualization can be extremely helpful.
            WalkNodes(prim.GetPrimIndex().GetRootNode());

            if (selectedAttribute != null && selectedAttribute.IsValid())
            {
                DrawAttributeInfo(scene);
            }
        }