コード例 #1
0
ファイル: StateRef.cs プロジェクト: yika-aixi/UnityFramework
            public IEnumerator PerformState(StateMachineComponent stateMachine, GameObject sourceObject = null)
            {
                State state = GetState(sourceObject != null ? sourceObject : stateMachine.gameObject);

                if (state != null)
                {
#if UNITY_EDITOR && DEBUG
                    string debugFileName = _file.GetFilePath();
                    StateMachineDebug.OnStateStarted(stateMachine, state, debugFileName);
#endif
                    return(state.PerformState(stateMachine));
                }

                return(null);
            }
コード例 #2
0
                private static AssetRef <T> AssetRefField <T>(AssetRef <T> assetRef, GUIContent label, ref bool dataChanged) where T : UnityEngine.Object
                {
                    if (label == null)
                    {
                        label = new GUIContent();
                    }

                    label.text += " (" + assetRef + ")";

                    bool editorCollapsed = !EditorGUILayout.Foldout(!assetRef._editorCollapsed, label);

                    if (editorCollapsed != assetRef._editorCollapsed)
                    {
                        assetRef._editorCollapsed = editorCollapsed;
                        dataChanged = true;
                    }

                    if (!editorCollapsed)
                    {
                        int origIndent = EditorGUI.indentLevel;
                        EditorGUI.indentLevel++;

                        T asset = EditorGUILayout.ObjectField("File", assetRef._editorAsset, typeof(T), false) as T;

                        //If asset changed update GUIDS
                        if (assetRef._editorAsset != asset || assetRef.GetFilePath() != AssetDatabase.GetAssetPath(asset))
                        {
                            if (asset != null && !AssetUtils.IsAssetInResources(asset))
                            {
                                asset = null;
                                UnityEngine.Debug.LogError("Asset needs to be in Resources folder.");
                            }

                            assetRef    = new AssetRef <T>(asset);
                            dataChanged = true;
                        }

                        EditorGUI.indentLevel = origIndent;
                    }

                    return(assetRef);
                }