Example #1
0
        public void SearchAsset()
        {
            AssetSelector selector = (AssetSelector)Activator.CreateInstance(mSelectorType);

            selector.Show();
            selector.SelectedAssetChanged += (comp, args) =>
            {
                SelectedAssetGuid = selector.SelectedAsset.Guid;
                AssetChanged?.Invoke(this, args);
            };
        }
Example #2
0
    private Dictionary <RobotColor, Material> sophiaMaterials;                         // Maps from robot color to actual materials for the Sophia robot model.

    // Handle avatar selector instancing between scene loads.
    void Awake()
    {
        // If there is no instance, let this be the new instance, otherwise, destroy this object.
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        // If this object was set as the instance, make sure it is not destroyed on scene loads.
        DontDestroyOnLoad(gameObject);
    }
Example #3
0
    // Instantiates the player avatar with the specified traits at the player
    // agent's positions as a child of the agent. Disables the default capsule mesh renderer.
    public void LoadPlayerAvatar(Gender gender, SkinColor skinColor)
    {
        // Get the desired player avatar model prefab.
        AssetSelector assetSelector = GameObject.Find("AssetSelector").GetComponent <AssetSelector>();
        GameObject    avatarPrefab  = assetSelector.GetPlayerAvatar(gender);

        // If there is such a model.
        if (avatarPrefab != null)
        {
            // Find player agent game object, instantiate the model as a child, apply color and disable the capsule renderer.
            GameObject playerAgent = GameObject.Find("PlayerAgent");
            GameObject playerClone = Instantiate(avatarPrefab, playerAgent.transform);
            assetSelector.ApplyPlayerColor(playerClone, gender, skinColor);
            playerAgent.GetComponent <MeshRenderer>().enabled = false;
        }
    }
Example #4
0
    // Instantiates the robot avatar of the specified type at the robot agent's
    // positions as a child of the agent. Disables the default capsule mesh renderer.
    public void LoadRobotAvatar(RobotType type, RobotColor color)
    {
        // Get the desired robot avatar model prefab.
        AssetSelector assetSelector = GameObject.Find("AssetSelector").GetComponent <AssetSelector>();
        GameObject    robotPrefab   = assetSelector.GetRobotAvatar(type);

        // If there is such a model.
        if (robotPrefab != null)
        {
            // Find robot agent game object, instantiate the model as a child, apply color and disable to capsule renderer.
            GameObject robotAgent = GameObject.Find("RobotAgent");
            GameObject robotClone = Instantiate(robotPrefab, robotAgent.transform);
            assetSelector.ApplyRobotColor(robotClone, type, color);
            robotAgent.GetComponent <MeshRenderer>().enabled   = false;
            robotAgent.GetComponent <CapsuleCollider>().radius = assetSelector.colliderRadii[type];
            robotAgent.GetComponent <RobotController>().UpdateWidth();
        }
    }
Example #5
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            EditorGUI.BeginProperty(pos, label, prop);

            Object oldClip = prop.objectReferenceValue;

            float toolbarStart = pos.width - fullToolbarSize;

            Rect rect = new Rect(pos.x, pos.y, toolbarStart, EditorGUIUtility.singleLineHeight);

            if ((attribute as PreviewedAudioAttribute).useAssetSelector)
            {
                AssetSelector.Draw(typeof(AudioClip), rect, prop, label, null);
            }
            else
            {
                EditorGUI.PropertyField(rect, prop, label);
            }

            if (oldClip != prop.objectReferenceValue)
            {
                EditorAudioTools.StopClip(oldClip as AudioClip);
            }

            GUITools.DrawToolbarDivider(pos.x + toolbarStart, pos.y);
            GUI.enabled = prop.objectReferenceValue != null;

            pos = new Rect(pos.x + toolbarStart + GUITools.toolbarDividerSize, pos.y, optionsToolbarSize, EditorGUIUtility.singleLineHeight);
            AudioClip   newClip = prop.objectReferenceValue as AudioClip;
            AudioSource source;
            bool        isPlaying = EditorAudioTools.IsClipPlaying(newClip, out source);

            DrawPlayStopButton(newClip, pos.x, pos.y, isPlaying, isPlaying && !source.loop, playGUI, false, prop.serializedObject.targetObject);
            DrawPlayStopButton(newClip, pos.x + GUITools.iconButtonWidth, pos.y, isPlaying, isPlaying && source.loop, playGUILooped, true, prop.serializedObject.targetObject);

            GUI.enabled = true;

            EditorGUI.EndProperty();
        }
        void OnGUI()
        {
            GUITools.Space(3);
            EditorGUI.BeginChangeCheck();

            windowObject.Update();

            if (GUILayout.Button("Refresh Game Settings"))
            {
                GameSettingsList.RefreshGameSettingsList();
            }

            EditorGUILayout.LabelField("Choose Settings:", EditorStyles.boldLabel);
            AssetSelector.Draw(typeof(GameSettingsObject), selectedSettingsProp, GUIContent.none, OnAssetsLoaded, null);
            windowObject.ApplyModifiedProperties();

            if (EditorGUI.EndChangeCheck())
            {
                OnChangedCurrentObject();
            }

            EditorGUILayout.Space();

            if (selectedSettings == null)
            {
                return;
            }

            if (settingsEditor == null)
            {
                CreateEditor();
            }

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            // draw the object
            settingsEditor.OnInspectorGUI();
            EditorGUILayout.EndScrollView();
        }
Example #7
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            UnityEngine.Object oldClip = prop.objectReferenceValue;

            Rect rect = new Rect(pos.x, pos.y, pos.width - fullToolbarSize, EditorGUIUtility.singleLineHeight);

            if ((attribute as PreviewedAudioAttribute).useAssetSelector)
            {
                AssetSelector.Draw(typeof(AudioClip), rect, prop, label, null, null);
            }
            else
            {
                EditorGUI.PropertyField(rect, prop, label);
            }

            float toolbarStart = pos.x + pos.width - fullToolbarSize;

            if (oldClip != prop.objectReferenceValue)
            {
                EditorAudioTools.StopClip(oldClip as AudioClip);
            }

            GUITools.DrawToolbarDivider(toolbarStart, pos.y);
            GUI.enabled = prop.objectReferenceValue != null;

            AudioClip newClip = prop.objectReferenceValue as AudioClip;

            AudioSource source;
            bool        isPlaying = EditorAudioTools.IsClipPlaying(newClip, out source);

            float xStart = toolbarStart + GUITools.toolbarDividerSize;

            UnityEngine.Object targetObject = prop.serializedObject.targetObject;
            DrawPlayStopButton(newClip, xStart + GUITools.iconButtonWidth * 0, pos.y, isPlaying, isPlaying && !source.loop, BuiltInIcons.GetIcon("preAudioPlayOff", "Play Clip"), false, targetObject);
            DrawPlayStopButton(newClip, xStart + GUITools.iconButtonWidth * 1, pos.y, isPlaying, isPlaying && source.loop, BuiltInIcons.GetIcon("preAudioLoopOff", "Play Clip Looped"), true, targetObject);

            GUI.enabled = true;
        }
Example #8
0
        public static void DrawPrefabReference(PrefabReference reference, GUIContent label, Action <string> onCollectionPicked, Action <string> onPrefabPicked)
        {
            if (!string.IsNullOrEmpty(label.text))
            {
                GUITools.Label(label, GUITools.black, GUITools.boldLabel);
            }

            AssetSelector.DrawName(typeof(PrefabReferenceCollection), reference.collection, new GUIContent("Collection"), null, null, onCollectionPicked);

            if (!string.IsNullOrEmpty(reference.collection))
            {
                EditorGUILayout.BeginHorizontal();
                GUITools.Label(new GUIContent("Prefab"), GUITools.black, GUITools.label, GUILayout.Width(EditorGUIUtility.labelWidth));

                if (GUITools.Button(new GUIContent(reference.name), GUITools.white, GUITools.popup, GUITools.black))
                {
                    PrefabReferenceCollection refObject = GameSettings.GetSettings <PrefabReferenceCollection>(reference.collection);
                    if (refObject != null)
                    {
                        GenericMenu menu = new GenericMenu();
                        for (int i = 0; i < refObject.prefabs.Length; i++)
                        {
                            if (refObject.prefabs[i] != null)
                            {
                                string name = refObject.prefabs[i].name;
                                menu.AddItem(new GUIContent(name), name == reference.name, () => onPrefabPicked(name));
                            }
                        }
                        menu.ShowAsContext();
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            // return reference;
        }